Jump to content

Contact form help with php - 05.14.11


mrjap1

Recommended Posts

Hello All,

 

I made an external "Thank you.html" page that I want to show immediately after the " Send Your Info"  button on my "request_more_info.php " form is clicked. This MUST stay external always. I want this to be called in somehow by php. So is there some php code I can use to accomplish this?

 

Also is there some php code I can use to validate my entire form and ESPECIALLY the e-mail address portion on my form? If so could you tell me who do i apply it to my "request_more_info.php "

 

Salutation: (radio buttons)

First Name: (input field)

Last Name: (input field)

Address: (input field)

City: (input field)

State: (select option)

Zip: (input field)

Country: (select option)

Email: (input field)

Our Newsletter: (radio buttons)

 

 

Thx

MrJAP1

Link to comment
Share on other sites

Here's the way I do validation:

 

When the user submits the form it is submitted to a new page, on that page:

$name=$_POST['name'];
if($name==""){
$error0=1;
}
else{
$error0=0;
}

 

Do the above for each item you want to validate. Incrementing the number after error in the $error variable.

 

i.e; $error0,$ error1, $error2, ect.

 

Once you review each form item forward the user back to the form or to your thank you page, via a header redirect.

if($error!=="0000000"){
header("Location: ./request_more_info.php?error=".$error0."".$error1."".$error2."".$error3."".$error4."".$error5."".$error6."");
}
else{
header("Location: URL for thank you page");

 

To alter the above you would have to take the total amount of form items you are validating, and place that amount of "0" in this:

if($error!=="0000000"){

 

 

And then on your initial submitting form:

 

$error=$_GET['error'];
<p><label>Name:</label> <input type="text" name="name" size="30"  />';
if($error[0]==1){ $content.=' <span class="red bold">This field is required.</span>'; }
$content.='</p>

 

So your flow is essentially:

 

submitting form ----> process/validate form

 

if errors, redirect back to submitting form with error=error code in URL

else, no errors, forward to thank you page

 

 

You'll need to alter this above code to suit your needs better, especially the CSS class calls and what not.

Link to comment
Share on other sites

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.