So I have validated and sanitized my form data on the same document. I was thinking it was safe until I started seeing stuff about the 'my_real_escape_string'. 
I am thinking that my data will be secure if I enter it how I have it but am not wanting to take the chance. So my question is do I need to use this 'my_real_escape_string' to ensure data security.
I am using the code below. First will be the form document (index.php) itself and then processing document(processform.php). Thanks for any and all help.
//index.php
<?php
// define variables and set to empty values
$first_nameErr = $last_nameErr = $emailErr = $passwordErr = $genderErr = "";
$first_name = $last_name = $email = $password = $gender = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST["first_name"]))
 {$first_nameErr = "";}
else
 {
 $first_name = test_input($_POST["first_name"]);
 // check if name only contains letters and whitespace
 if (!preg_match("/^[a-zA-Z ]*$/",$first_name))
   {
   $first_nameErr = "Only letters allowed";
   }
  }
if (empty($_POST["last_name"]))
 {$last_nameErr = "";}
else
 {
 $last_name = test_input($_POST["last_name"]);
 // check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$last_name))
   {
   $last_nameErr = "Only letters allowed";
   }
 }
if (empty($_POST["email"]))
  {$emailErr = "";}
else
 {
 $email = test_input($_POST["email"]);
 // check if e-mail address syntax is valid
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
   {
   $emailErr = "Invalid email format";
   }
  }
if (empty($_POST["password"]))
 {$passwordErr = "";}
else
 {$password = test_input($_POST["password"]);}
if (empty($_POST["gender"]))
 {$genderErr = "";}
else
 {$gender = test_input($_POST["gender"]);}
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<div class="signupitsfree" float="right">
<p class="signup">Sign Up<br />It's Completely Free!</p>
<form method="POST" name="signup" action="processform.php">
<label for="first name"></label><input id="first name" name="first_name" 
placeholder="First Name" type="text" value="<?php echo $first_name;?>" /> <span  
class="error">* <?php echo $first_nameErr;?></span>
<label for="last_name"></label><input id="last name" name="last_name"  
placeholder="Last 
Name" type="text" value="<?php echo $last_name;?>" />
<span class="error">* <?php echo $last_nameErr;?></span>
<br><br>
<label for="email"></label><input id="email" name="email" placeholder="Email"    
type="text" value="<?php echo $email;?>" />
<span class="error">* <?php echo $emailErr;?></span>
<br /><br />
<label for="password"></label><input id="password" name="password" 
placeholder="Create  
Password" type="password" />
<span class="error">* <?php echo $passwordErr;?></span>
<br /><br />
<label for="male"><strong>Male</strong></label> <input id="male" value="male" 
<?php if (isset($gender) && $gender=="male") echo "checked";?> 
name="gender" type="radio" /> 
<label for="female"><strong>Female</strong></label> <input id="female" value="female" 
<?php if (isset($gender) && $gender=="female") echo "checked";?> name="gender"  
type="radio" />
<span class="error">* <?php echo $genderErr;?></span>
<br /><br />
<label for="submit">"I Agree To <a href="#">Terms And Conditions"</a></label>  
//BELOW IS 'PROCESSFORM.PHP'
<?php
 $hostname="this is correct";
 $username="thisalso";
 $password="chicken";
 $dbname="chiken also";
  $db_conx = mysqli_connect($hostname, $username, $password) OR DIE ("Unable to
  connect to database! Please try again later.");
  if(mysqli_connect_errno()){
  echo mysqli_connect_error();
  exit();
  }
  $select = mysqli_select_db($db_conx,$dbname);
  $first_name= $_POST["first_name"];
  $last_name= $_POST["last_name"];
  $email= $_POST["email"];
  $password= $_POST["password"];
  $gender= $_POST["gender"];
  mysqli_query($db_conx,"INSERT INTO users (firstname, lastname, email, password,   gender)
  VALUES ('$first_name', '$last_name', '$email', '$password', '$gender')");
  mysqli_close($db_conx);
  header("Location: anotherpage.php")
  ?>
 
    