mysql - PHP: How to check if ID in database exists -
Why will not this send the user to user.php if the ID is not present in the table?
& lt ;? Php included 'db_connect.php'; $ Id_exists = false; $ Url_id = mysql_real_escape_string ($ _GET ['id']); $ Sql = "Selection ID from members where id = '$ url_id'"; $ Result = mysql_query ($ sql); If ($ result == $ url_id) {$ id_exists = true; } And if ($ result! = $ Url_id) {$ id_exists = false; Header ("location: user.php"); Go out(); }? & Gt; Thx in advance!
$ url_id = mysql_real_escape_string ($ _elected ['id']); $ Sql = "Selection ID from members where id = '$ url_id'"; $ Result = mysql_query ($ sql); If (mysql_num_rows ($ result) & gt; 0) {// found} else {// not found} try something like that :).
Comments
Post a Comment