title: PHP TO MySQL secured with MySQLi and hyperlink redirect not working once submitted
body: <p>I had a Freelancer work on a site for me and could not finish my project which should of been of ease to him and I need to get this fully running to be ready by morning.</p>
  
  <p>This is my PHP code which I had to create in a hurry </p>
  
  <pre><code>&lt;?php
  
  $con = mysqli_connect('localhost','dbuser','password'
  
  if(!$con)
  {
          echo 'Not Connected To Server';
  }
  
  if(!mysqli_select_db($con,'DBName'))
  {
      echo 'Database Not Selected';
  }
  
  $UserN = $_POST['UserN'];
  $FullN = $_POST['FullN'];
  $Adrs  = $_POST['Adrs'];
  $Email = $_POST['Email'];
  $PhoneN = $_POST['PhoneN'];
  
  $sql = "INSERT INTO UserIn (UserN, FullN, Adrs, Email, PhoneN) VALUES ('$UserN', '$FullN', '$Adrs', '$Email', '$PhoneN')";
  
  if(!mysqli_query($con,$sql))
  {
          echo 'Not Inserted';
  }
  else
  {
      echo 'Inserted';
  }
  
  header("refresh:2; url=survey.html
  
  ?&gt;
  </code></pre>
  
  <p>this is PHP</p>
  
  <p>this is my Form </p>
  
  <pre><code> &lt;div class="form-con"&gt;
           &lt;form actoin="insert.php" method="post"&gt;
               &lt;label&gt;Username&lt;/label&gt;&lt;br&gt;
               &lt;input type="text" name="UserN" placeholder="Your Username" &gt;&lt;br&gt;
               &lt;label&gt;Full Name&lt;/label&gt;&lt;br&gt;
               &lt;input type="text" name="FullN" placeholder="Full Name"&gt;&lt;br&gt;
               &lt;label&gt;Full Address&lt;/label&gt;&lt;br&gt;
               &lt;textarea type="text" rows="4" cols="50" name="Adrs" placeholder="Address"&gt;&lt;/textarea&gt;&lt;br&gt; 
                    &lt;label&gt;Email Address&lt;/label&gt;&lt;br&gt;
                    &lt;input type="email" name="Email" placeholder="Email Address"&gt;&lt;br&gt;
                    &lt;label&gt;Phone Number&lt;/label&gt;&lt;br&gt;
                    &lt;input type="text" name="PhoneN" placeholder="Phone Number"&gt;&lt;br&gt;
                     &lt;div class="btn"&gt;
                       &lt;a href="survey.html"&gt;&lt;button type="submit"&gt;Submit&lt;/button&gt;&lt;/a&gt;
                     &lt;/div&gt;
           &lt;/form&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p>Please help me I want to also secure the form with</p>
  
  <pre><code>Using MySQLi (for MySQL):
  $stmt = $dbConnection-&gt;prepare('SELECT * FROM employees WHERE name = ?');
  $stmt-&gt;bind_param('s', $name);
  
  $stmt-&gt;execute();
  
  $result = $stmt-&gt;get_result();
  while ($row = $result-&gt;fetch_assoc()) {
      // do something with $row
  }
  
  From here
  
  https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php?rq=1
  
  please help.
  </code></pre>
  
  <p>New PHP </p>
  
  <pre><code>&lt;?php
  
  $dbh = new PDO("mysql:host=$host;dbame=$dbname",$user,$pass);
  
  $UserN = mysqli_real_escape_string($con, $_POST['UserN']);
      $FullN = mysqli_real_escape_string($con, $_POST['FullN']);
      $Adrs = mysqli_real_escape_string($con, $_POST['Adrs']);
  $Email = mysqli_real_escape_string($con, $_POST['Email']);
  $PhoneN = mysqli_real_escape_string($con, $_POST['PhoneN']);
  </code></pre>
  
  <p>$stmt = $dbh->prepare("INSERT INTO UserIn (UserN, FullN, Adrs, Email, PhoneN) VALUES ('$UserN','$FullN','$Adrs','$Email','$PhoneN')");        //Insert query
  $stmt->execute($UserN, $FullN, $Adrs, $Email, $PhoneN); </p>
  
  <pre><code>header("refresh:1; url=survey.html");
  
  ?&gt;
  </code></pre>