Jump to content

wiggly

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wiggly's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [code] Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Server\Apache2\htdocs\login2\register.php on line 45 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Server\Apache2\htdocs\login2\register.php on line 46 [/code] these are the errors i get when i use this piece of code however when i take the code out i get no errors what i want to do is add code to my register.php to stop people registering with a username and email address that is already registered. here is my code with the above problems removed maybee that will be more helpfull to you [code] <? include('include/db_connect.php'); $first = $_POST['first']; $last = $_POST['last']; $email = $_POST['email']; $phone = $_POST['phone']; $user = $_POST['user']; $pass = $_POST['pass']; $info = $_POST['info']; $first = stripslashes($first); $last = stripslashes($last); $email = stripslashes($email); $phone = stripslashes($phone); $user = stripslashes($user); $pass = stripslashes($pass); $info = stripslashes($info); if((!$first) || (!$last) || (!$email) || (!$user) || (!$pass)){     echo '<strong>You must fill in all required fields!!!</strong> <br />';     if(!$first){         echo "You must fill in the First Name field! <br />";     }     if(!$last){         echo "You must fill in the Last Name field! <br />";     }     if(!$email){         echo "You must fill in the E-Mail field! <br />";     }     if(!$user){         echo "You must fill in the Username field! <br />";     }     if(!$pass){         echo "You must fill in the Password field! <br />";     }     include 'register.html';     exit(); } $pass=md5($pass); $sql = mysql_query("INSERT INTO users (first, last, email, phone, user, pass, info) VALUES('$first', '$last', '$email', '$phone', '$user', '$pass', '$info')")     or die (mysql_error());      if(!$sql){     echo 'There has been a problem during the registration process please try again later! <br />'; } else{ $userid = mysql_insert_id();     echo 'Your account was created sucsesfully <br />'; } ?> [/code]
  2. Hi i am a complete newbe to php and thus i dont know very much however i have started writing a registration/login system for my website and i can not seem to figure out how to stop duplicate usernames or email addresses i have managed to get the actualy registration part working and i just need a bit of advice on how i could stop multiple people using the same details. i did find a tutorial that i tried to use some code from on phpfreaks and i had no luck. this is the code i tried: $sql_email_check = mysql_query("SELECT email form users WHERE email_address='$email"); $sql_username_check = mysql_query("SELECT username from users WHERE username='$username'"); $email_check = mysql_num_rows($sql_email_check); $username_check = mysql_num_rows($sql_username_check); if(($mail_check > 0) || ($username_check > 0)){ echo "Please fix the following errors: <br />"; if($email_check > 0){ echo "<strong>Your Email Address has already been used by another member in our database please submit a diffrent Email Address!</strong> <br />"; unset($email); } if($username_check > 0){ echo "<strong>The Username you selected has alreadey been used by another member in our database. Please choose a diffrent Username</strong> <br />"; unset($username); } i would be most greatfull if someone could help me as i have been bugged for the past week with this problem, maybee i have just typed somthing wrong or missed somthing out i have no idea.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.