hello,
i have a 3 form in my site in different pages, let's say page1.php, page2.php and page3.php.
the form method is set to post, and action is set to processform.php
what i would like to ask here (coding the processform.php)
since the form is basically similar (sending an email but using fixed different destination).
1. how i detect from which page processform.php invoked (page1.php, page2.php, or page3.php) ?
so i can use if statement to process send email to different email address for each page.
2. how do i redirect and use "post" or "get" method back from processform.php to invoker page? so i can return an error message or successful message. (or maybe in php there is common technique to applying my needs here?)
thank you , please help.
need help, newbie to php want to implement form.
Moderator: General Moderators
Re: need help, newbie to php want to implement form.
The easiest way would be to have two processform.php pages. Have one input page call processform1.php and the other processform2.php. Then make the appropriate changes to processform2.php to reflect the destination and error return form.dxplus wrote:hello,
i have a 3 form in my site in different pages, let's say page1.php, page2.php and page3.php.
the form method is set to post, and action is set to processform.php
what i would like to ask here (coding the processform.php)
since the form is basically similar (sending an email but using fixed different destination).
1. how i detect from which page processform.php invoked (page1.php, page2.php, or page3.php) ?
so i can use if statement to process send email to different email address for each page.
2. how do i redirect and use "post" or "get" method back from processform.php to invoker page? so i can return an error message or successful message. (or maybe in php there is common technique to applying my needs here?)
thank you , please help.
Of course you could put a hardcoded varible in each calling form and then use if- else in the one called form. But that seems like the hard way to me.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
In the pages that have the form, enter a hidden field that is called refering_page, then add the name of the page that the form is on to that field.
Code: Select all
<input type="text" name="refering_page" value="<?php echo basename($_SERVER['SCRIPT_FILENAME']); ?>" />