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
\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");
  }
 
 
  ?>
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.
Thanks for the suggestions.  However, I don't know
if I can do what you suggested because the collected
data 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 do
know html and would be able to redirect an regular
html form just fine.

Do you have any other suggestions?

Thanks again!
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.
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 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
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]
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.