Jump to content

Recommended Posts

i have made my own add user script and i need some help with the password bit, i want to be able to check if confirm password is the same as password, and i would also like to check if the email has a @ symbol in it.

 

my code:

 

<?php
  $email = $_POST['email'] ;
  $first = $_POST['nameFirst'] ;
  $last = $_POST['nameLast'] ;
  $username = $_POST['username'] ;
  $password = $_POST['password'] ;
  $cpassword = $_POST['cpassword'] ;
  $age = $_POST['age'] ;
  $gender = $_POST['gender'] ;
  $ip=$_SERVER['REMOTE_ADDR']; 

  if ($first == "") {
    echo "Error: You havent entered your first name<br/><br/>";
  }
  elseif ($last == "") {
    echo "Error: You havent entered your last name<br/><br/>";
  }
  elseif ($username == "") {
    echo "Error: You havent entered your username<br/><br/>";
  }
  elseif ($password == "") {
    echo "Error: You havent entered your password<br/><br/>";
  }
  elseif ($cpassword == $password") {
    echo "Error: You havent confirmed your password properly<br/><br/>";
  }
  elseif ($email == "") {
    echo "Error: You havent entered your email<br/><br/>";
  }
  elseif ($age == "" || $age < 13) {
    echo "Error: You must be 13 or over to join<br/><br/>";
  }
  elseif ($age == "Age (e.g. 14)") {
    echo "Error: You havent entered your age<br/><br/>";
  }
  elseif ($gender == "" || $gender != "Male" || $gender != "male" || $gender != "female" || $gender != "Female" ) {
    echo "Error: You havent entered your gender<br/><br/>";
  }
  else {
  include ('includes/mysql_connect_users');
  $mysqlinsert="INSERT INTO users(username, password, email, firstname, lastname, age, gender, ip)VALUES('$username', '$password', '$email', '$first', '$last', '$age', '$gender', '$ip')";
  
  $result2=mysql_query($mysqlinsert);

if($result2){
echo "<div align='center'><h4><strong><u>Write This Information Down</u></strong></h4><br/><br/>";
echo "<u><strong>Your Login Information</strong></u><br/><br/>";
echo "Your Registered Username:".$username."<br/><br/>";
echo "Your Registered Password:".$password."<br/><br/><br/>";
echo "<u><strong>Other Information</strong></u><br/><br/>";
echo "Your Registered Name Is:".$first. $last."<br/><br/>";
echo "Your Registered Email:".$email."<br/><br/>";
echo "Your Registered Age:".$age."<br/><br/>";
echo "Your Registered Gender:".$gender."<br/><br/><br/><br/>";
echo "You Are Successfully Registered,";
echo "Click <a href='index.php'>Here</a>";
echo "To Return To The Homepage";
}
}
?>

 

can someone help?

Link to comment
https://forums.phpfreaks.com/topic/55564-help-with-add-user/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.