I have a form that people can fill out on a webpage. Once they fill it out they have a choice of three buttons to press. The buttons call a javascript to check that all the boxes are filled in. If they arent then the user is sent back to the field to fill it in correctly. This works fine. BUT no matter what i change (button to a submit or vice versa, adding the different 1.php, 2.php 3.php into the javascript or the onsubmit of the form or the button etc) nothing seems to work. I can put the first location (1.php) into the forms action and call the javascript from the onsubmit (of the form) but even when i have these set it the onclick="document.forms.frmForm.action='2.php';" etc it still calls from 1.php
The java script is the same for all the buttons but the buttons SHOULD send the data to 1.php or 2.php or 3.php depending what the user clicks... the best i can get it is to all submit to 1.php or nothing at all.
Any help would be appreciated asap
Thanks
Submitting Form to several locations with different buttons
Moderator: General Moderators
-
cvmflinchy
- Forum Newbie
- Posts: 13
- Joined: Sat Feb 06, 2010 12:58 pm
-
limitdesigns
- Forum Commoner
- Posts: 25
- Joined: Sat Feb 06, 2010 9:05 pm
Re: Submitting Form to several locations with different buttons
Here's what I would do:
Have the form go to one location. From there, you can route it to one of the three places. You could save all the $_POST variables as session variables, and then route it according to the value of your radio buttons.
Have the form go to one location. From there, you can route it to one of the three places. You could save all the $_POST variables as session variables, and then route it according to the value of your radio buttons.
Re: Submitting Form to several locations with different buttons
I agree! That does make the most sense. Besides that, you can perform any processing on that single page you need to such as data validation so you're passing clean data on to other places.
-
cvmflinchy
- Forum Newbie
- Posts: 13
- Joined: Sat Feb 06, 2010 12:58 pm
Re: Submitting Form to several locations with different buttons
thanks guys ive done it now. I used other buttons to change the action of the form and then submit it in two steps.
Now for my next problem.
I have one text input
I want the user to be able to type several email address into it (seperated by "; ") and the code.php will change the $to = to each email address and send it. i understand i need to use a while function. i do NOT want each email to see all the email addresses on it though just the one its being sent to.
any help?
Now for my next problem.
I have one text input
I want the user to be able to type several email address into it (seperated by "; ") and the code.php will change the $to = to each email address and send it. i understand i need to use a while function. i do NOT want each email to see all the email addresses on it though just the one its being sent to.
any help?
Re: Submitting Form to several locations with different buttons
parse the string and put it in array and then loop through the array to send the email. Don't forget to validate each email address. This should be helpful: http://htmlfixit.com/cgi-tutes/tutorial ... String.php
-
cvmflinchy
- Forum Newbie
- Posts: 13
- Joined: Sat Feb 06, 2010 12:58 pm
Re: Submitting Form to several locations with different buttons
i followed your link and im finally getting there. for some reason though i get this error:
if txtTo only has one email address in and $to1 = $toemail or "my email" then it works but not with this code.
any idea?
ps. i made a new topic so ill post there
even though this is in my codeerror wrote: Warning: mail() expects parameter 1 to be string, array given in /home/sites/leisure-supplies.co.uk/public_html/admin/newsletter.submit.php on line 30
Newsletter delivery failed... Please try again.
Code: Select all
$toemail = $_REQUEST['txtTo'];
while ( $splitdata = explode('; ', $toemail))
{
$to1 = $splitdata;
line 30: if (mail($to1, $subject1, $body1, $headers1)) {any idea?
ps. i made a new topic so ill post there