skip to Main Content

I made a registration form that takes email, username, firstname, etc…Only Password will not store in the database upon submission.

The field is declared correctly in the HTML file, password is set to varchar, all the other variables post but I can’t pinpoint why not this password field.

Please find below my set up:(php 5.6.39)
enter image description here

So i corrected the “.” after Username on line 25, but now it’s weird.
it still doesn’t post to the then actually outputs my error message “First Name and Last Name is a required field and cannot be blank.”

    $required = array('Email','FirstName','LastName', 'Username', 'Password');
     // Loop over field names, make sure each one exists and is not empty 
    $error = false;
    foreach($required as $field){
      if (empty($_POST[$field])) {
          $error = true; 
      } 
    } 
    if ($error) {
        echo "First Name and Last Name is a required field and 
    cannot be blank."; 
   } else {
        echo " Awesome, you filled it all in! ";
   }

even when all fields are submitted

3

Answers


  1. Try This,

    $uname = (!empty($_POST['UserName'])) ? $_POST['UserName'] : $uname;
    $pword = (!empty($_POST['Password'])) ? $_POST['Password'] : $pword;
    

    Warning for Sql Injection
    Don’t use direct $_POST try to sanitize it first,

    Login or Signup to reply.
  2. Hey you put full stop instead of comma after UserName :

    ‘Username’,’Password’

    Login or Signup to reply.
  3. $uname = (isset($_SESSION['Username']) ? $_SESSION['Username'] : NULL);
    $pword = (isset($_SESSION['Password']) ? $_SESSION['Password'] : NULL);
    $uname = (isset($_POST['Username']) ? $_POST['Username'] : $uname);
    $pword = (isset($_POST['Password']) ? $_POST['Password'] : $pword);
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search