Ne.OnZ Posted April 10, 2008 Author Share Posted April 10, 2008 What do you mean, I did define them. Before it goes into the error function, I have this in the code: $query = "INSERT INTO users(username, password, email, rank) VALUES('$username', '$password', '$email', '1')"; $result = mysql_query($query); So they are defined there. And in the check function, I have defined like so: $query = "SELECT `username` FROM `users` WHERE `username` = '$username'"; $result = mysql_query($query) or die("Problem with the query: $query<br />" . mysql_error()); So I don't understand you D: Link to comment https://forums.phpfreaks.com/topic/98755-register-script-not-working-d/page/3/#findComment-513922 Share on other sites More sharing options...
darkfreaks Posted April 10, 2008 Share Posted April 10, 2008 ok i added an else if statement to function "check" so that if result equals zero to do nothing else error. <?php require("includes/Connect.php"); mysql_select_db("divnx5_web"); $username = $_POST['user']; $password = sha1($_POST['pass']); $password2 = sha1($_POST['pass2']); $email = $_POST['email']; function error($result, $query) { if(!$result) { echo "Query Failed: $query<br />" . mysql_errno() . '<br />' . mysql_error(); } } function check($username) { $query = "SELECT `username` FROM `users` WHERE `username` = '$username'"; $result = mysql_query($query) or die("Problem with the query: $query<br />" . mysql_error()); if (mysql_num_rows($result) > 0) echo "The username " . $username . ' is already taken!<br /><br />'; else if (mysql_num_rows($result)==0) } if(!$con) { echo "Registering is disabled right now, please check back later"; } else { if(!$_POST['register']) { echo "<br /><br />Use the following form to register a new account with us. <form action='register.php' method='post'><br /><br /> <font size='2'>Username:</font><br /> <input type='text' id='user' name='user' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br /> <font size='2'>Password:</font><br /> <input type='password' id='pass' name='pass' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br /> <font size='2'>Confirm Password:</font><br /> <input type='password' id='pass2' name='pass2' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br /> <font size='2'>E-mail Address:</font><br /> <input type='text' id='email' name='email' size='20' style='background-color: #FFFFFF; font-size: 8pt; border: 1 solid #003399' /><br /><br /> <input type='submit' name='register' id='register' value='Register' style='background-color: #FFFFFF; color: #000000; font-size: 8pt; border: 1 solid #003399' /> <input type='reset' value='Clear' style='background-color: #FFFFFF; color: #000000; font-size: 8pt; border: 1 solid #003399' /> </form>"; } else { if(!isset($username) || empty($username)) { echo "The username you entered encountered a problem<br />"; check($username); } if(!$password || !$password2 || !isset($password) || !isset($password2) || empty($password) || empty($password2)) { echo "The password field(s) cannot be left empty.<br />"; } if(!$email || !isset($email) || empty($email)) { echo "The email you entered encountered a problem<br />"; } if($password != $password2) { echo "The passwords you entered do not match<br />"; } else { if(isset($username) || $password == $password2|| isset($email) || !empty($email) || !empty($username)||check($username)) { $query = "INSERT INTO users(username, password, email, rank) VALUES('$username', '$password', '$email', '1')"; $result2 = mysql_query($query); error($result, $query); mysql_close($con); echo "Thank You for registering with us " . $username . '! Before you can login and start using the features of the site, please check the email you provided (' . $email . ') for a confirmation link.'; } } } } ?> Link to comment https://forums.phpfreaks.com/topic/98755-register-script-not-working-d/page/3/#findComment-514013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.