Question

I have a simple html form.

<form name="cmxform" method="post" action="projecthandler.php" id="doxform"> 

<tr>

    <td><input name="firstname" type="text" size="40"></font></td>
  </tr>
<tr>

</tr>
<tr>

    <td><input name="lastname" type="text" size="40"></td>
  </tr>
</form>

And the projecthandler.php scrpit sends email to user

<?php

if(isset($_POST['firstname'])) {

   $email_to = "shruti15sargam@gmail.com";
   $email_subject = "Project Subject";
   $email_subject_user = "Confirmation";

    $firstname = $_POST['firstname']; // required

    $lastname = $_POST['lastname']; // required




    $email_message = "Form details below.\n\n";
    $email_message_user = "Thank you....";



    function clean_string($string) {

      $bad = array("content-type","bcc:","to:","cc:","href");

      return str_replace($bad,"",$string);

    }



    $email_message .= "First Name: ".clean_string($firstname)."\n";

    $email_message .= "Last Name: ".clean_string($lastname)."\n";





// create email headers

$headers = 'From: '.$Email."\r\n".

'Reply-To: '.$email_from."\r\n" .

'X-Mailer: PHP/' . phpversion();


mail($Email, $email_subject_user, $email_message, 'From: donotreply@somemail.edu');
header('Location: thanks.html');


?>



 <div>
echo "Hello World";
        </div>

The final thanks.html page needs to display these first and last name values on it as form data. How can I echo the results from this form to the confirmation(thanks.html) page. Thanks.

Was it helpful?

Solution

You could either send the values in the url www.mydomain.co.uk?value1=val&value2=val2

and then get the data from there (assuming you are okay with this security wise). Or like it has already been mentioned you could set session values:

ie:

<?php

session_start();
$_SESSION['value1'] = $val;
$_SESSION['value2'] = $val2;

sessions are probably the way to go tbh.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top