-1

i want ask, is there any How to short my script

First Check, if get uid, do Second and Third check

$result = mysqli_fetch_row(mysqli_query($con, "SELECT MAX(`uid`) FROM `pvpgn_bnet`"));
if($result) {
    Do Second and First Check();
}

Second Check

$result = mysqli_fetch_row(mysqli_query($con, "SELECT * FROM `pvpgn_bnet` WHERE acct_email = '" . $email . "'"));
    if($result) {
        errorMsg();
    }

Third Check

$result = mysqli_fetch_array(mysqli_query($con, "SELECT `uid` FROM `pvpgn_bnet` WHERE acct_username = '" . $username . "'"), MYSQLI_BOTH);
if($result) {
    errorMsg();
}
Putra Fajar Hasanuddin
  • 1,101
  • 3
  • 13
  • 25

1 Answers1

1

I dont know what the first filter is for (it doesnt make sense), but the second and third can be combined. Consider this example:

$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$stmt = $mysqli->prepare("SELECT * FROM pvpgn_bnet WHERE acct_email=? OR acct_username=?")
$stmt->bind_param("ss", $email, $username);
$stmt->execute();
// other processes

$res = $stmt->get_result();
while($row = $res->fetch_array(MYSQLI_ASSOC)) {
    // what ever you want to do here
}
user1978142
  • 7,946
  • 3
  • 17
  • 20