I have the a php file that contains the following
- an html file which is used to collect data for a new user
- php functions that validate the input data
- javascript codes that alerts and prompt the user before data submission
- after the validation process I want to move the input data to an insert.php to insert data into the database.
Below is the code
<?PHP
session_start();
if (!(isset($_SESSION['login_user']) && $_SESSION['login_user'] != '')) {
header ("Location: loginForm.php");
}
$hash;
$salt;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="layout.css">
<script language="javascript" type="text/javascript" src="/templates/myjavascript.js"></script>
<title>Title of the document</title>
<script>
  window.onload=function(){
    document.getElementById("new_user_form").onsubmit=function(){
        if(this.pword.value === this.pword2.value)
           { alert("Are you sure you want to create a new user")
               return true;}
         else{ alert("Paswords must be the same ");
             return false;}
      }
  }
</script>
</head>
<div>
<body>
<section id="content">
<form align="center" class="form" action="create_user.php" method="post" id="new_user_form" name="new_user_form">
<ul>
<li>
<h2>Please Fill The Form</h2>
</li>
<li>
     <label for="username">User Name</label> 
        <input name="username" id="keyword" type="text" placeholder="type first name (required)" required />             
</li>
<li>
     <label for="pword">Password</label>
     <input name="pword" id="pword" type="password" placeholder="########" required />
</li>
<li>
     <label for="pword2">Confirm Password</label>
     <input name="pword2" id="pword2" type="password" placeholder="########" required />
</li>
<p>
          <input type = "reset" class="reset" name="submit"/>
          <input type ="submit" name="submit" value="submit" class="submit" "/>
        </p>    
</section>
</ul>
</form>
</body>
</div>
<?php
 /* php function to check pasword policy 
     The password has to be alphanumeric and special characters minimum 8 and max 16               
                    */                   
function checkpwdPolicy(){
      if($_POST['pword'] === $_POST['pword2']) {
  if(!preg_match('/^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,16}$/', $_POST['pword'])) {
  echo '<script> alert(" password requirement not met"); </script>';
} else{
 /* we use the session varible to store the hashed password and username   */
                                                      /
 $_SESSION['pwd'] = password_hash($_POST['pword'], PASSWORD_DEFAULT);
 $_SESSION['username'] = $_POST['username'];
 header ("Location: insert_user_table.php");
  }
} 
  else {echo "passwords do not match  "; }
}
 //tis is used to call the fucntion that checks the password policy                                      
if(isset($_POST['submit']) && isset($_POST['username']) && isset($_POST['pword']) && isset($_POST['pword2']) )
{checkpwdPolicy();}
?>
</html>
How ever when I run the cod I get the following error displayed. Below is the error.
The question is how to move the data to the file that will do the insertion of data into database.

 
     
     
     
     
    