Forum Moderators: coopster
I've created a 2 page application form in html. Once the person has completed the first page and submits, I send an email with the form data using a php which then redirects to a second .html page. Once the second page has been filled out, and the person click submit, a second php is run and I receive a second email with the data from the second page.
I need to be able to pass the person's last name from the first page to the second in order to know who has filled out the second page.
Is there a way to send data from one form to another through a php script?
Help!? :S
The form information is available to your PHP script via the $_POST or $_GET superglobals. You can move information using PHP just as you would with any other form processing script. For example, sessions, cookies, or hidden <input> fields. For example, let's say your first page has a form processing script called page2.php. In that script, as you are building your HTML form, simply bury the value of the last name field from the POSTed data from page1 in your page2 <form> as follows:
<input type="hidden" name="lastname" value="<?php print $_POST['lastname'];?>" />
PHP Tutorial [php.net]
Php, Mysql, Apache, Netscape 4.78
how do i start my php adventure? [webmasterworld.com]
new to programming
therefore new to PHP [webmasterworld.com]
<?php
$email = $HTTP_POST_VARS[ContactEmail];
$mailto = "****@****.com";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailsubj = "Application Submission 1 of 2";
$mailbody = "NEW APPLICATION\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{$mailbody .= "$key : $val\n";}
mail($mailto, $mailsubj, $mailbody, $mailhead);
header("Location: [domainname.com...]
exit;
?>
From what I understand, in page2.html, i need to add: <input type="hidden" name="lastname" value="<?php print $_POST['lastname'];?>" />
What do I need to add in my email.php file to get the data from page1.html?
Thanks!
There are still a couple of ways to do this. One would be to append a query string to your redirected URL and make it a PHP parsed page:
header("Location: h**p://www.domainname.com/page2.php?lastname=" .
htmlentities [php.net]($HTTP_POST_VARS['lastname']));
Another approach would be to mail the information off in
email.php, then instead of redirecting, replace the header redirect with the HTML that you currently have in page2.php. Either way, your choice. There's more than one way to do it!
Yes, using PHP :) The data from the form has to put their dynamically in this case, correct? What I mean is that
lastname is a variable whose data changes for each unique user that fills out the form. If you have a hard-coded html form for the second page, when they SUBMIT the second page, it will POST any <input> variables found in the <form>. How are you going to get the lastname variable into your form if it is standard html and not processed by a PHP parser? I imagine you could use javascript somehow, but we are looking for a PHP solution. Am I misunderstanding your goal somehow?
The site that I'm working with uses SSI's, and to include these SSI's my main pages need to be .html pages. Unless, there is a way to modify the .htaccess file so that .php files are parsed as html.
I've got page1.html that has a form that the user fills out, which includes their last name as a unique identifier. Once the person click submit, email.php is run and send out an email with the details of the form on page1.html. In email.php, thre is a header that then redirects and opens up page2.html which is page 2 of the application form. If they choose to fill this out, then a second email is sent.
This would all work fine if I was able to save page2 as a .php file vs a .html file...but then my includes for my ssi's will not work.
Am I making any sense? If the solution is to simply hard code the second page and forget about the SSI's I will do so, but this is not a preferred option.
Sorry to be such a pain :S. I'll be sure to become a little more familiar with PHP after this project ;)
There is a way to parse html as php [httpd.apache.org], but you may not need to do that. Read on...
>>This would all work fine if I was able to save page2 as a .php file vs a .html file...but then my includes for my ssi's will not work.
You can use PHP's include [php.net] function in place of your SSI statements. When a file is included, parsing drops out of PHP mode and into HTML mode at the beginning of the target file, and resumes again at the end. For example, let's say you have a SSI that is a top navigation bar in your html. With PHP, you simply include that file:
<html><head><title>Title</title></head><body>
<?php include("topnav.html");?>
<form>
<input type="hidden" name="lastname" value="<?php print $_POST['lastname'];?>" />
<!-- More HTML here -->
</form>
</body></html>