Jump to content

Recommended Posts

I know there has to be a very simple solution
to this problem, however my programmer left
me hanging so I have to figure this out for
myself... 

My form processing code is below.  How can
I modify it so that visitors are redirected to a
thank you page after the successful
submission 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");
}


?>
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.
*wildteen88*

I'm not getting a blank screen, the page just
stays the same.  You can see what I mean by
sumbitting the form at http://www.AllCreditIsOK.com/application.htm
(just use ficticious info)



*thorpe*

I added the line of code that you said, but
it is still not working.  It might be because I
added that redirect function myself and I
don't quite know what I'm doing.

Any other thouhgts?


Thank you both for your assistance!
  • 2 weeks later...
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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.