eFlame Posted April 25, 2008 Share Posted April 25, 2008 Im quite new to php and am trying to make a signup script, so far my script contains the registration form, and the registration info, but when i try to use it i get a error, and i don't know what to do. reg_info.php <? include("config.php"); $check[0] = mysql_query("SELECT email FROM Account WHERE email = '$email'"); $check[1] = mysql_query("SELECT username FROM Account WHERE username = '$username'"); function user_valid($user) { if(!isset($user)) { $status = 0; $msg = $msg . "You have not inserted a username <br />"; } elseif(6 > strlen($user)) { $status = 0; $msg = $msg . "Your username must be longer than 5 characters <br />"; } elseif(strlen($user) > 30) { $status = 0; $msg = $msg . "Your username must be shorter or equal to 30 characters long <br />"; } else { $status = 1; $msg = $msg . ""; } } function pass_valid($pass, $pass2) { if(!isset($pass)) { $status = 0; $msg = $msg . "You need to enter a password <br />"; } elseif($pass != $pass2) { $status = 0; $msg = $msg . "Both passwords need to match <br />"; } elseif( 6 > strlen($pass)) { $status = 0; $msg = $msg . "Password must be longer than 5 characters <br />"; } elseif(strlen($pass) > 32) { $status = 0; $msg = $msg . "Password must be shorter or equal to 32 characters <br />"; } else { $status = 1; $msg = $msg . ""; } } function email_valid($mail) { if(!isset($mail)) { $status = 0; $msg = $msg . "Email must be entered <br />"; } elseif(6 > strlen($mail)) { $status = 0; $msg = $msg . "Email must be longer than 5 Characters long <br />"; } elseif(strlen($mail) > 30) { $status = 0; $msg = $msg . "Email must be shorter or equal to 30 characters long <br />"; } } function misc_valid($u_name, $e_mail) { if(mysql_num_rows($check[0])) { $status = 0; $msg = $msg . "Your email has already been taken. If you have forgotten your password use the forgot password link <br />"; } elseif(mysql_num_rows($check[1])) { $status = 0; $msg = $msg . "Your chosen username has already been used. Please go back and pick another <br />"; } else { $status = 1; $msg = $msg . ""; } } if(isset($reg) && $reg == "reg258741") { $status = 1; $msg = " "; user_valid($username); pass_valid($password, $password2); email_valid($email); misc_valid($username, $email); $md5password = md5($password); if($status == 0) { echo "<color = 'red'>" . $msg . "</color> <br /> <a href = 'register.php'> Go Back and try again </a>"; } else { mysql_query("INSERT INTO Account (username, password, email) VALUES ($username, $md5password, $email)"); echo "<color = 'green'> You have successfully registered <br />"; echo "An email has been sent to the email address provided you will need to activate your account before logging in <br />"; echo "Please <a href = 'login.php'>login here</a>"; } } else { echo "Please use the registration form"; } ?> config.php <? // Database Variables // $con = mysql_connect("localhost", "*******", "*********"); $db = "********"; // Form Variables // $username = $_POST['username']; $password = $_POST['password']; $password2 = $_POST['password2']; $email = $_POST['email']; $terms = $_POST['terms']; $reg = $_POST['reg258741']; ?> the error appears in the misc_valid function where im using mysql_num_rows, any help please Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted April 25, 2008 Share Posted April 25, 2008 what error do you get? Quote Link to comment Share on other sites More sharing options...
eFlame Posted April 25, 2008 Author Share Posted April 25, 2008 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource i get the error twice, once for each mysql_num_rows, and then it says account created successfully when it hasn't been made in the database. Quote Link to comment Share on other sites More sharing options...
eFlame Posted April 25, 2008 Author Share Posted April 25, 2008 Any help?? Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 25, 2008 Share Posted April 25, 2008 You get that error becuase of an invalid SQL query or you don't have a Mysql connection. Check that your SQL queries are correct. Note: You can't select the username and password independantly, they you need to check the username and password simultainiously. Here is a tutorial about login systems: http://www.phpcodinghelp.com/article.php?article=user-login Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.