Hi everyone looking for a little help im making a registry system however i need to check to see if there is a key already in the database so a user cant just insert a random key here is my codes if anyone can help me…
[php]<?php include "base.php"; ?>
<?php if(!empty($_POST['username']) && !empty($_POST['password'])) { $username = mysql_real_escape_string($_POST['username']); $password = md5(mysql_real_escape_string($_POST['password'])); $password2 = md5(mysql_real_escape_string($_POST['password_conf'])); $email = mysql_real_escape_string($_POST['email']); $location = mysql_real_escape_string($_POST['location']); $vcode = mysql_real_escape_string($_POST['vcode']); $checkusername = mysql_query("SELECT * FROM MineCraft_Login WHERE username = '".$username."'"); $checkcode = mysql_query ("SELECT * FROM MineCraft_Login WHERE vouchercode = '".$vcode."'"); $checkkeys = mysql_query ("SELECT * FROM keys WHERE Key = '".$vcode."'"); $checkcode3 = mysql_query ("SELECT * FROM keys WHERE Used = 'Y'"); $print = mysql_query ("SELECT * FROM keys"); if(mysql_num_rows($checkusername) == 1 ) { echo "Error
"; echo "Sorry, that username is taken. Please go back and try again.
"; } elseif ($password != $password2){ echo "Error
"; echo "Your passwords need to be the same
"; } elseif (mysql_num_rows($checkcode) == 1 and mysql_num_rows($checkkeys) != 1){ echo "Error
"; echo "This voucher code is in use
"; } else { $registerquery = mysql_query("INSERT INTO MineCraft_Login (username, password, email, location , vouchercode) VALUES('".$username."', '".$password."', '".$email."' , '".$location."','".$vcode."')"); if($registerquery) { echo "Success
"; echo "Your account was successfully created. Please click here to login.
"; } else { echo "Error
"; echo "Sorry, your registration failed. Please go back and try again.
"; } } }[/php]