I have a php page that does a job after a form is submitted. the form enters data into a database then the next page queries the database and creats and sends an email based on the info entered into the form. I need that page to redirect back to the original form after sending the email.
<?php
$con = mysqli_connect('localhost','username','password');
if(!$con)
{
echo 'Not Connected To Server';
}
if(!mysqli_select_db($con,'dbname'))
{
echo 'Database Not Selected';
}
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$sql = "INSERT INTO tablename (Name,Email) VALUES ('$Name','$Email')";
if(!mysqli_query($con,$sql))
{
echo 'Not Inserted';
}
else
{
echo 'Blah Blah Blah Yackity Schmackity';
$id = $con->insert_id; // Get latest inserted id.
$to = $Email;
$subject = 'Subject Line Here';
$message = '<center><img src="http://domainname.com/images/Banner.jpg" />
</center><br><br>start of email text here<b> "'.$Name.'"</b> Your Member ID
is "'.$id.'"Rest of email text here.
';
$headers = 'From: email@domainname.com' . "\r\n" .
'Reply-To: email@domainname.com' . "\r\n" .
'Content-Type: text/html' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
} ?>