youngsuccess Posted January 2, 2007 Share Posted January 2, 2007 I know there has to be a very simple solutionto this problem, however my programmer left me hanging so I have to figure this out for myself... 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<br/>\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()); function Redirect($time, $topage) { echo "<meta http-equiv=\"refresh\" content=\"{$time}; url={$topage}\" /> ";} $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="[email protected]"; $mail_to2="[email protected]"; $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/32585-help-how-to-redirect-visitor-after-form-submission/ Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 Instead of....[code=php:0]print_r("Customer information was successfully added");[/code]Place....[code=php:0]Redirect(0,"thankyoupage.php");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32585-help-how-to-redirect-visitor-after-form-submission/#findComment-151549 Share on other sites More sharing options...
wildteen88 Posted January 2, 2007 Share Posted January 2, 2007 Change where it says:[code=php:0]print_r("Customer information was successfully added"); [/code]this:[code=php:0]header("Location: pagename.php")[/code]Change pagename.php to the page you want to the user to be redirected too. Note before using this function make sure there is nothing being outputted to the browser before you use the function. Quote Link to comment https://forums.phpfreaks.com/topic/32585-help-how-to-redirect-visitor-after-form-submission/#findComment-151552 Share on other sites More sharing options...
youngsuccess Posted January 2, 2007 Author Share Posted January 2, 2007 I think there is something being outputted to the browser before this function. Howdo I correct that? Quote Link to comment https://forums.phpfreaks.com/topic/32585-help-how-to-redirect-visitor-after-form-submission/#findComment-151676 Share on other sites More sharing options...
wildteen88 Posted January 2, 2007 Share Posted January 2, 2007 Do you get any errors or a blank screen? Quote Link to comment https://forums.phpfreaks.com/topic/32585-help-how-to-redirect-visitor-after-form-submission/#findComment-151690 Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 Just use the line I gave you, you have the redirect() function defined within your code. Quote Link to comment https://forums.phpfreaks.com/topic/32585-help-how-to-redirect-visitor-after-form-submission/#findComment-151694 Share on other sites More sharing options...
youngsuccess Posted January 5, 2007 Author Share Posted January 5, 2007 *wildteen88*I'm not getting a blank screen, the page juststays the same. You can see what I mean bysumbitting the form at http://www.AllCreditIsOK.com/application.htm(just use ficticious info)*thorpe*I added the line of code that you said, butit is still not working. It might be because Iadded that redirect function myself and Idon't quite know what I'm doing.Any other thouhgts?Thank you both for your assistance! Quote Link to comment https://forums.phpfreaks.com/topic/32585-help-how-to-redirect-visitor-after-form-submission/#findComment-153208 Share on other sites More sharing options...
wildteen88 Posted January 13, 2007 Share Posted January 13, 2007 Usee thorpe's code. I didnt realise there was a function setup for redirections in your code.You are using AJAX to submit the form. There may be an problem within your javascript that's causing this. Quote Link to comment https://forums.phpfreaks.com/topic/32585-help-how-to-redirect-visitor-after-form-submission/#findComment-159912 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.