views:

56

answers:

4

I need to send form values from one page to another and from that page to a third page. I would need the form values from the first page in the third page. How can I do it?

I have the code that transfers form values to the next page. How can I send the same form values to the third page?

<script type="text/javascript" src="jquery-1.2.6.min.js"></script>

 <script type="text/javascript">                                         
   // we will add our javascript code here           

$(document).ready(function(){
$("#ajax-contact-form").submit(function(){

var str = $(this).serialize();

   $.ajax({
   type: "POST",
   url: "contact.php",
   data: str,
   success: function(msg){

$("#note").ajaxComplete(function(event, request, settings){

if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
{
result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
window.location.href = "http://www.google.com";
$("#fields").hide();
}
else
{
result = msg;
}

$(this).html(result);

});

}

 });

return false;

});

});

 </script>  
A: 

Use sessions - here is a Tutorial

mplungjan
its just a html page.. not sure if we can sessions here
Prady
If you have php to send mail, return page 3 with the values in a new form. Or have the php send the values to page3
mplungjan
A: 

You can set the values from Form #1 as input tags with hidden type in Form #2. That way, when you submit Form #2, values will be available in Form #3.

Pablo Santa Cruz
i dont have form in the second page. its just that the second page is a php page which sends email after which the form values from the page1 is redirected to page3
Prady
Then as others have suggested, you can store values in session...
Pablo Santa Cruz
+2  A: 

you can use GET

window.location.href = "http://yourdoamin?value= serialize text variable";
JapanPro
thanks... how can i read the values in the third page when i use GET? any example would be great
Prady
take a look at this: http://stackoverflow.com/questions/1352214/serialize-unserialize-in-jquery
Aditya Menon
i have updated post, please check it
JapanPro
+1  A: 

Assuming you're using only simple values (not passing arrays), you can do something like this:

echo "<form id='second_page' method='post' action='third_page.php'>";
foreach ($x in $_POST) {
    echo '<input type="hidden" name="' . htmlspecialchars($x) . '" value="' . htmlspecialchars($_POST[$x]) . '" />';
}
MightyE