I have a form which sends to my email. Once form is complete and submitted it redirects to a email sent conformation page. I want to display the name on this page grabbing it from the field in which they inserted their name.
EMAIL FORM PHP:
<?php
$your_email ='info@example.com';
session_start();
$errors = '';
$name = '';
$visitor_email = '';
$user_message = '';
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$user_message = $_POST['message'];
///------------Do Validations-------------
}
?>
header('Location: emailsent.php?name=' . $name);
In emailsent.php
echo $_GET['name'];
May I ask why are you using header('Location: emailsent.php');
? instead of using header you can reload the same page and modify it to show a different content if the email was sent.
<?php
if(isset($_POST['submit']) && empty($errors)) {
//show a success message and some html code... e.g.:
echo 'Thank you, '.$_POST['name']; //this is the senders name
}
?>
If you must use headers, here is a solution