youngsuccess Posted January 8, 2007 Share Posted January 8, 2007 I know there has to be a very simple solutionto this problem, however my programmer leftme hanging so I have to figure this out formyself... My form processing code is below. How canI modify it so that visitors are redirected to athank you page after the successfulsubmission of the form?Your help is much appreciated!Here is the code:========================================<?php //include("include/check.php"); include("include/db.php");/** * * * @version $Id$ * @copyright 2006 * */// Set up a query to select the required fields and records // Connect to the Oracle database $strFirstName=$_POST['strFirstName']; $strLastName=$_POST['strLastName']; $strHomePhone=$_POST['strHomePhone']; $strWorkPhone=$_POST['strWorkPhone']; $strCellPhone=$_POST['strCellPhone']; $strFaxNumber=$_POST['strFaxNumber']; $strBestTime=$_POST['strBestTime']; $strEmailAddress=$_POST['strEmailAddress']; $strCurrentStreet=$_POST['strCurrentStreet']; $strCurrentCity=$_POST['strCurrentCity']; $strCurrentState=$_POST['strCurrentState']; $strZipCode=$_POST['strZipCode']; $strDesiredSquareFootage=$_POST['strDesiredSquareFootage']; $strNumberOfBedrooms=$_POST['strNumberOfBedrooms']; $strNumberOfBathrooms=$_POST['$strNumberOfBathrooms']; $strDesiredMovedate=$_POST['strDesiredMovedate']; $strMaximumMonth=$_POST['strMaximumMonth']; $strMaximumDown=$_POST['strMaximumDown']; $strHousePrice=$_POST['strHousePrice']; $strAddtionalComments=$_POST['strAddtionalComments']; $strHearFrom=$_POST['strHearFrom']; $strHearAboutUse=$_POST['strHearAboutUse']; $strCities=$_POST['strCities']; //echo "All Info was loaded to database"; $queryString=" INSERT INTO `creditok_customers` (`firstname` , `lastname` , `homephone` , `workphone` , `mobile` , `fax` , `best_time_contact` , `email` , `address1` , `address2` , `address3` , `address4` , `status` , `time` )"; $queryString.=" VALUES('$strFirstName', '$strLastName', '$strHomePhone', '$strWorkPhone', '$strBestTime', '$strCellPhone', '$strFaxNumber', '$strEmailAddress', '$strCurrentStreet', '$strCurrentCity', '$strCurrentState', '$strZipCode', 'ACTIVE', curdate())"; //echo("Query string:$queryString\n"); $r = mysql_query($queryString) or die(mysql_error()); //$queryString="INSERT INTO `creditok_customers` (`firstname` , `lastname` , `homephone` , `workphone` , `mobile` , `fax` , //`best_time_contact` , `email` , `address1` , `address2` , `address3` , `address4` , `status` , `time` ) //VALUES ('$strFirstName', '$strLastName', '$strHomePhone', '$strWorkPhone', '$strBestTime', '$strCellPhone', '$strFaxNumber', //'$strEmailAddress', '$strCurrentStreet', '$strCurrentCity', '$strCurrentState', '$strZipCode', 'Active', NOW( ) //);" //$r = mysql_query($queryString) or die(mysql_error()); $numberOfRows= mysql_affected_rows(); if ($numberOfRows>0) { $queryString="Select `id` from `creditok_customers` where email='$strEmailAddress'"; $r = mysql_query($queryString) or die(mysql_error()); $numberOfRows= mysql_num_rows($r); $CustId=""; while ($row = mysql_fetch_array($r)){ $CustId=$row['id']; } if ($CustId=="") { print_r("Server is unable to process the application form at the moment, please come back later"); } else { $queryString="INSERT INTO `creditok_dreamhome` ( `cust_id` , `squ_ft` , `no_bedroom` , `no_bathroom` , `moving_date` , `desired_cities` , `min_mth_pay` , `max_mth_pay` , `price` , `comment` , `heard_from` , `specify` )"; $queryString.="VALUES ('$CustId', '$strDesiredSquareFootage', '$strNumberOfBedrooms', '$strNumberOfBathrooms', '$strDesiredMovedate', '$strCities', '$strMaximumDown', '$strMaximumMonth', '$strHousePrice', '$strAddtionalComments', '$strHearFrom','$strHearAboutUse')"; $ri = mysql_query($queryString) or die(mysql_error()); $numberOfRows= mysql_affected_rows(); if ($numberOfRows>0) { $mail_to1="sailboatvn@googlemail.com"; $mail_to2="marcus@marcuscurryinc.com"; $mail_from="AllCreditIsOK.com"; $mail_sub="Quick Approval Application from $strFirstName $strLastName"; $mail_mesg = "New owner finance prospect info... \r\n \r\n"; $mail_mesg .="================================ \r\n"; $mail_mesg .=" CONTACT INFORMATION \r\n"; $mail_mesg .="================================ \r\n"; $mail_mesg .="Buyer Name: $strFirstName $strLastName \r\n"; $mail_mesg .="Home Phone: $strHomePhone \r\n"; $mail_mesg .="Work Phone: $strWorkPhone \r\n"; $mail_mesg .="Cell Phone: $strCellPhone \r\n"; $mail_mesg .="Fax Number: $strFaxNumber \r\n"; $mail_mesg .="Best Time: $strBestTime \r\n"; $mail_mesg .="Email: $strEmailAddress \r\n"; $mail_mesg .="Address: $strCurrentStreet, $strCurrentCity, $strCurrentState $strZipCode \r\n \r\n"; $mail_mesg .="================================ \r\n"; $mail_mesg .=" DESIRED HOME INFORMATION \r\n"; $mail_mesg .="================================ \r\n"; $mail_mesg .="Desired SF: $strDesiredSquareFootage \r\n"; $mail_mesg .="Bedrooms: $strNumberOfBedrooms \r\n"; $mail_mesg .="Bathrooms: $strNumberOfBathrooms \r\n"; $mail_mesg .="Move Date: $strDesiredMovedate \r\n"; $mail_mesg .="Cities: $strCities \r\n \r\n"; $mail_mesg .="================================ \r\n"; $mail_mesg .=" FINANCIAL INFORMATION \r\n"; $mail_mesg .="================================ \r\n"; $mail_mesg .="Mthly Pmnt: $strMaximumMonth \r\n"; $mail_mesg .="Down Pmnt: $strMaximumDown \r\n \r\n"; $mail_mesg .="================================ \r\n"; $mail_mesg .=" MISCELLANEOUS INFORMATION \r\n"; $mail_mesg .="================================ \r\n"; $mail_mesg .="Comments: $strAddtionalComments \r\n \r\n"; $mail_mesg .="Referred By: $strHearFrom \r\n"; $mail_mesg .="Specify: $strHearAboutUse \r\n \r\n"; $mail_mesg .= "Please click on the link to view more detail : \r\n"; $mail_mesg .= "http://www.AllCreditIsOK.com/sailboatvn/CustomerDetail.php?id=$CustId"; mail($mail_to1,$mail_sub,$mail_mesg,'From:$mail_from'); mail($mail_to2,$mail_sub,$mail_mesg,'From:AllCreditIsOK.com'); print_r("Customer information was successfully added"); } else { print_r("Server is unable to process the application form at the moment, please come back later"); } } } else { print_r("Server is unable to process the application form at the moment, please come back later"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/33343-help-how-to-redirect-visitor-after-form-submssion/ Share on other sites More sharing options...
soycharliente Posted January 8, 2007 Share Posted January 8, 2007 If you're using a <form> with this then try adding an action.Example:<form action="page.ext" method="post">//the form</form>On submitting the form, all input fields will post and the user will be directed to 'page.ext'.By the way, I wouldn't post that much code. I didn't even really read it (I just skimmed through it).Try attaching a file if yo're going to post that much code. You can choose the additional options link underneath the posting window to attach a file. Quote Link to comment https://forums.phpfreaks.com/topic/33343-help-how-to-redirect-visitor-after-form-submssion/#findComment-155802 Share on other sites More sharing options...
Jessica Posted January 8, 2007 Share Posted January 8, 2007 I second, process on a seperate page, and then they'll be on another page for you. Quote Link to comment https://forums.phpfreaks.com/topic/33343-help-how-to-redirect-visitor-after-form-submssion/#findComment-155806 Share on other sites More sharing options...
youngsuccess Posted January 8, 2007 Author Share Posted January 8, 2007 Thanks for the suggestions. However, I don't knowif I can do what you suggested because the collecteddata is being stored in a database.I am a PHP novice (understatement), so I have no idea if what I am saying makes sense to you or not. I doknow html and would be able to redirect an regularhtml form just fine.Do you have any other suggestions?Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/33343-help-how-to-redirect-visitor-after-form-submssion/#findComment-155984 Share on other sites More sharing options...
soycharliente Posted January 10, 2007 Share Posted January 10, 2007 What I suggested was your simple HTML form "redirect". The HTML form handles where the user goes on submission.Your question was "How to redirect visitor after form submssion?" And then you said..[quote author=youngsuccess link=topic=121513.msg499944#msg499944 date=1168284030]I do know html and would be able to redirect an regular html form just fine.[/quote]According to your question, it sounds like you know exactly what the answer is. Maybe I just don't understand exactly what you are looking for. Quote Link to comment https://forums.phpfreaks.com/topic/33343-help-how-to-redirect-visitor-after-form-submssion/#findComment-157021 Share on other sites More sharing options...
bubblybabs Posted January 10, 2007 Share Posted January 10, 2007 Put this at the bottom of your form:header("Refresh: 0;url=http://webpageurl.com");and see if that works...Edit: I should clarify that you would have the form include a page called redirect.php with the above code in it and once it is called the page will automatically redirect...Babs Quote Link to comment https://forums.phpfreaks.com/topic/33343-help-how-to-redirect-visitor-after-form-submssion/#findComment-157075 Share on other sites More sharing options...
magic2goodil Posted January 10, 2007 Share Posted January 10, 2007 [quote author=bubblybabs link=topic=121513.msg501053#msg501053 date=1168399733]Put this at the bottom of your form:header("Refresh: 0;url=http://webpageurl.com");and see if that works...Babs[/quote]i fear since he already has prints and an include, this will lead to a headers already sent error Quote Link to comment https://forums.phpfreaks.com/topic/33343-help-how-to-redirect-visitor-after-form-submssion/#findComment-157078 Share on other sites More sharing options...
bubblybabs Posted January 10, 2007 Share Posted January 10, 2007 OOo, you are quick! While I was typing in my edit to my original note you aptly posted this... You are correct, the way I typed it in at first would cause an error...Babs[quote author=magic2goodil link=topic=121513.msg501056#msg501056 date=1168399894][quote author=bubblybabs link=topic=121513.msg501053#msg501053 date=1168399733]Put this at the bottom of your form:header("Refresh: 0;url=http://webpageurl.com");and see if that works...Babs[/quote]i fear since he already has prints and an include, this will lead to a headers already sent error[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/33343-help-how-to-redirect-visitor-after-form-submssion/#findComment-157080 Share on other sites More sharing options...
magic2goodil Posted January 10, 2007 Share Posted January 10, 2007 lol :P Quote Link to comment https://forums.phpfreaks.com/topic/33343-help-how-to-redirect-visitor-after-form-submssion/#findComment-157082 Share on other sites More sharing options...
soycharliente Posted January 10, 2007 Share Posted January 10, 2007 @bubblybabs: using header() isn't a very cross-browser safe function in my opinion. Quote Link to comment https://forums.phpfreaks.com/topic/33343-help-how-to-redirect-visitor-after-form-submssion/#findComment-157159 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.