Connect HTML form to Database using PHP

I have an HTML form (code below), and my goal is to submit user-generated data to the database so that they can later login using the stored information. I'm using MAMP.

The problem: I created a PHP file to process this data and send it to the database, but when I press "submit" the only thing I get is a page that repeats my PHP code. I tried saving the files into my htdocs folder and got a 404 error.

I know that variations of this question have been asked before, but still haven't found a solution that works. I did a "Hello World" test using PHP and it worked fine, so I think everything is connected/installed correctly. Would really appreciate any advice!

Here's my HTML:

<label>Username</label>
<input type="text" id="name" name="name" placeholder="Choose a Username" required>
<span class="error"><?php echo $nameErr;?></span>
<br>

<label>Email address:</label>
<input type="text" id="email_addr" name="email_addr" placeholder="Enter your Email" required>
<span class="error"><?php echo $email_addrErr;?></span>
<br>

<label>Confirm email address:</label>
<input type="text" id="email_addr_repeat" name="email_addr_repeat" placeholder="Confirm email address" required oninput="check(this)">
<span class="error"><?php echo $email_addr_repeatErr;?></span>
<br>

<label>Create a password:</label>
<input type="password" id="password" name="password" placeholder="Create a Password" required>
<span class="error"><?php echo $passwordErr;?></span>
<br>

<label>Confirm password:</label>
<input type="password" id="password_repeat" name="password_repeat" placeholder="Confirm Password" required oninput="check(this)">
<span class="error"><?php echo $password_repeatErr;?></span>
<br>

<input type="submit" id="button" name="submit" value="Submit">

Here's my PHP:

    if( $_POST )
        {
      $con = mysql_connect("localhost");

      if (!$con)
      {
        die('Could not connect: ' . mysql_error());
      }

      mysql_select_db("mydatabase", $con);

      $users_name = $_POST['name'];
      $users_email = $_POST['email_addr'];
      $users_email_two = $_POST['email_addr_repeat'];
      $users_password = $_POST['password'];
      $users_password_two = $_POST['password_repeat'];

      $query = " INSERT INTO `mydatabase`.`registration` (`name`,`email_addr`,`email_addr_repeat`, `password`,`password_repeat`) VALUES (NULL, '$users_name','$users_email','$users_email_two','$users_password',   '$users_password_two')";
      mysql_query($query);

      echo "<h2>Thank you for registering!</h2>";

      mysql_close($con);
    }

Answers


Column count does not match value count. What is being inserted as NULL?

INSERT INTO `mydatabase`.`registration` (`name`, `email_addr`,   
`email_addr_repeat`, `password`,
    `password_repeat`) VALUES (NULL, '$users_name',
    '$users_email', '$users_email_two','$users_password',       
'$users_password_two');

should be

INSERT INTO `mydatabase`.`registration` (`NULL_COLUMN`, `name`, `email_addr`,   
`email_addr_repeat`, `password`,
    `password_repeat`) VALUES (NULL, '$users_name',
    '$users_email', '$users_email_two','$users_password',       
'$users_password_two');

where NULL COLUMN is the column that is being inserted asNULL.

Also, mysql_* functions are deprecated and removed in PHP 7. Use PDO or MySQLi.


Remove NULL value from insert query :

$query = " INSERT INTO mydatabase.registration (name, email_addr, email_addr_repeat, password, password_repeat) VALUES ('$users_name', '$users_email', '$users_email_two','$users_password', '$users_password_two')"; 

Need Your Help

Anchor hover and adjacent sibling

html css hover

Imagine this html structure:

Login Form with passphrase

php mysql login

I am having trouble with my login form, I am trying to make the user login with their email address, password and a passphrase however it is not letting me login, even though I am using correct