reddog Posted October 9, 2011 Share Posted October 9, 2011 Hello freaks, I can't seem to figure out why code not working correctly. Any advise greatly apprechiated. <?php include_once('connect/mysqlconnect.php'); $user = $_POST['uname']; $email = $_POST['email']; $pass1 = $_POST['pass1']; $pass2 = $_POST['pass2']; $checkname = mysqli_query("SELECT * FROM users WHERE uname='$user'"); if(isset($_POST['submitted'])){ if(mysqli_num_rows($checkname) > 0) { $errors[] = 'User name not available, please choose different name'; } else { $u = mysqli_real_escape_string($dbc, $user); } if(!empty($email)) { $e = mysqli_real_escape_string($dbc, $email); } else { $errors[] = 'You did not enter email address!'; } if($pass1 == $_POST['pass2']) { $p = mysqli_real_escape_string($dbc, trim($pass1)); } else{ $errors[] = 'Your password did not match. Please try again.'; } if(empty($errors)) { $insert = "INSERT INTO users(uname, email, pass1, register_date) VALUES ('$u','$e',sha1('$p'), NOW(register_date))"; // This execute above statement to INSERT into database $r = mysqli_query($dbc, $insert); } if($r) { //Print a message: echo '<h1>Thank you!</h1> <p>You are now registered.</p><p><br /></p>'; } else { echo ',<h1>Server Error</h1> <p>You could not be registered do to a server error. We apologize for any inconvience.</p>'; } } mysqli_close($dbc); ?> Quote Link to comment https://forums.phpfreaks.com/topic/248729-user-registration-issue/ Share on other sites More sharing options...
MasterACE14 Posted October 9, 2011 Share Posted October 9, 2011 are you getting an error? Also please use [ code ] [ /code ] tags <?php include_once('connect/mysqlconnect.php'); $user = $_POST['uname']; $email = $_POST['email']; $pass1 = $_POST['pass1']; $pass2 = $_POST['pass2']; $checkname = mysqli_query("SELECT * FROM users WHERE uname='$user'"); if(isset($_POST['submitted'])){ if(mysqli_num_rows($checkname) > 0) { $errors[] = 'User name not available, please choose different name'; } else { $u = mysqli_real_escape_string($dbc, $user); } if(!empty($email)) { $e = mysqli_real_escape_string($dbc, $email); } else { $errors[] = 'You did not enter email address!'; } if($pass1 == $_POST['pass2']) { $p = mysqli_real_escape_string($dbc, trim($pass1)); } else{ $errors[] = 'Your password did not match. Please try again.'; } if(empty($errors)) { $insert = "INSERT INTO users(uname, email, pass1, register_date) VALUES ('$u','$e',sha1('$p'), NOW(register_date))"; // This execute above statement to INSERT into database $r = mysqli_query($dbc, $insert); } if($r) { //Print a message: echo '<h1>Thank you!</h1> <p>You are now registered.</p><p><br /></p>'; } else { echo ',<h1>Server Error</h1> <p>You could not be registered do to a server error. We apologize for any inconvience.</p>'; } } mysqli_close($dbc); Quote Link to comment https://forums.phpfreaks.com/topic/248729-user-registration-issue/#findComment-1277376 Share on other sites More sharing options...
reddog Posted October 9, 2011 Author Share Posted October 9, 2011 Here are the warning message I am getting. Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\wamp\www\sports\login.php on line 15 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\wamp\www\sports\login.php on line 18 Notice: Undefined variable: r in C:\wamp\www\sports\login.php on line 43 Quote Link to comment https://forums.phpfreaks.com/topic/248729-user-registration-issue/#findComment-1277543 Share on other sites More sharing options...
awjudd Posted October 9, 2011 Share Posted October 9, 2011 You need to provide mysqli_query the connection object that you get from mysqli_connect because of this the other errors are showing up. ~juddster Quote Link to comment https://forums.phpfreaks.com/topic/248729-user-registration-issue/#findComment-1277545 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.