Ismz Posted February 23, 2008 Share Posted February 23, 2008 Im pretty new to PHP, i got a question about form submission, do i have to have the php on the same page with the html in order for it to work? can anyone explain to me how i go about making a php form submission work? ??? Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/ Share on other sites More sharing options...
php_dave Posted February 23, 2008 Share Posted February 23, 2008 Hi, No your html form code can be a seperat file from the php processing section - check out http://www.tizag.com/phpT/forms.php Which gives a good example form processing with php. Cheers Dave Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474505 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 Thanks alot dave, but the problem i am having is with the redirecting part, in the html it submits the info to orderform.php, but after i hit the submit button it goes to the orderform.php page that is blank and had the default message on it, i want it to stay on the website but show a specific thank you message in one table on that page here is the php script and part of html im using Html code <form method="post" action="orderform.php"> <input type="hidden" name="recipient" value="123@yoursite"> <input type="hidden" name="subject" value="Online Survey...!!!!!!!"> <input type="hidden" name="redirect" value="http://www.yoursite.com/thankyou.html"> and this is the php script FormMail.php v5.0 Copyright 2000-2004 Ai Graphics and Joe Lumbroso © All rights reserved. Created 07/06/2000 Last Modified 10/28/2003 Joseph Lumbroso, http://www.aigraphics.com, http://www.dtheatre.com http://www.dtheatre.com/scripts/ I tried posting the script here but it says i dont have permission to access index.php on this server ??? Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474616 Share on other sites More sharing options...
smc Posted February 23, 2008 Share Posted February 23, 2008 Please clarify what you are trying to achieve. Are you trying to make it so that when they submit the form it processes the query but shows a different page? Basically this is what is happening: (Your Page With Forms) -- User Submits ---> (orderform.php) orderform.php then processes the form data using whatever PHP you have coded into it. If you want it to display a message you can do a simple: print( "My Message!" ); or echo( "My Message!" ); on the form before or after the data. Alternatively, if you want to process the data then display another page you can do: header( "location: myPage.php" ); The above will then redirect your page to myPage.php (providing you've not displayed any messages using print; or echo;. If you have printed any text from the PHP script you will receive a header error) Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474634 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 Hmmm, i am using that php script i got online, what im trying to do is have the php script submit the form info to an email and then after that i want it to redirect the to a thank you message right there on the same page they submitted the info from. does that makes sense? Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474638 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 here is the script i am using i attached it as a txt file to this post hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474643 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 ok i've been doing some reading on a google search, and it seems like i forgot to mention i am using an html page with the redirect command, the thing is the html page submits the form info to a php file which send that info to an email. i am also using the same orderform.php for more than form page, do i need to make multiple ordrform php pages for each html page with a form on it? i am so lost here ??? Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474676 Share on other sites More sharing options...
php_dave Posted February 23, 2008 Share Posted February 23, 2008 Hi Ismz, You dont need a unique orderform.php from what I can see. Although the script you have will not give you what you want - it seems it expects a redirect page as you supply in the hidden fields which after finishing processing and sending of the data it redirects to the page designated. If you want to be able to display messages on the original form that the user fills in you will have to make that form a .php file its self so you can handle the requests and build the page dynamically. Try building the page from scratch rather than using that script - it would be a lot easier. Dave Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474687 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 yea i kinda figured it was something along that line, thing is dave i really dont know php, and the pages on my site are all html i just found that php script n thought id give it a go, are u suggesting that i make my html pages in php? and in that case would each page be redirected after the form submits its info to the email? Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474693 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 Also, being that on the HTML pages i have the redirect code on each of them, shouldnt that make them redirect after the info submits? is there a way to do so? Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474697 Share on other sites More sharing options...
php_dave Posted February 23, 2008 Share Posted February 23, 2008 Yes it should redirect to the page you specify in the hidden fields (if that is not working that is an issue with the script itself!) If your site is big it could be a big re-write - depends how badly you want that info on the same page as the form.. you can do it 2 ways as i see it.. 1) Form.html -> orderform.php -> static redirect.html (can have as many of these as you need). You dont get info on same page 2) Form.php -> orderform.php -> form.php (handle response from orderform.php to build dynamic response). Big rewrite?!? If you choose the php route then just google php forms or something of that nature its not overly complicated. Good Luck! Dave Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474704 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 Thanks alot for your time dave i really appreciate it, lets say i wanna go with the static redirect.html what do u mean by i can have as many of these as i can? i have only 3 or 4 forms on the site total, and what do u mean i dont get info on the same page? Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474713 Share on other sites More sharing options...
php_dave Posted February 23, 2008 Share Posted February 23, 2008 No worries, From the way the script works it takes its redirect page from the form itself so for example if you had Form 1 = Registration form Hidden redirect = "reg_form_redirect.html" Form 2 = Forum form Hidden redirect = "forum_form_redirect.html" Form 3 = Misc Form Hidden redirect = "misc_redirect.html" That way you can tailor what the website returns after a certain form is submitted. Still you dont get your update on the same page deal though! Dave Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474716 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 But would i get the info submitted by the user in an email? Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474719 Share on other sites More sharing options...
php_dave Posted February 23, 2008 Share Posted February 23, 2008 Isnt that what the script does? - sorry i havent read it fully. The script would take the data - create the email - send to email addy specficed then redirect to page specified... Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474720 Share on other sites More sharing options...
budimir Posted February 23, 2008 Share Posted February 23, 2008 You can always put in your php script a line of code which would redirect to wanted page: header("Location: your_wanted_file.php"); You put it in the end of the file, and after all the code is executed it will show the page specified in the line above. Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474723 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 yes dave thats what it does but it doesnt redirect, and to budimir does the redirect page have to be in php or can it be an html page? Thanks so much for all the help. Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474727 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 BTW dave what is the exact code for the static redirect and where exactly in my html page do i add it? Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474728 Share on other sites More sharing options...
budimir Posted February 23, 2008 Share Posted February 23, 2008 You can put html page in header it will do the redirect. header ("Location: your_page.php"); header ("Location: your_page.html"); It will work. Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474730 Share on other sites More sharing options...
Ismz Posted February 23, 2008 Author Share Posted February 23, 2008 Alright thanks alot, ill give it a try and see it that works and ill post here when i do. :-) Quote Link to comment https://forums.phpfreaks.com/topic/92593-form-submission-help/#findComment-474753 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.