Jump to content

Why would a form only work sometimes?


Elle

Recommended Posts

Hi

 

I am only starting to learn PHP now and would appreciate some help. A while back I created a form and used a tool to create the PHP script for it. When I test the form online, it works most of the time but nevertheless it frequently does not submit the information. Often I go back and resubmit the same information and then it goes through.

 

I find that I'm more likely to get an error if I have not tested it for at least a few minutes, and also after I cleared my cache. I've searched for a solution but have not been successful and find it quite confusing.

 

Here is my PHP code:

<?php
// Receiving variables
@$pfw_ip= $_SERVER['REMOTE_ADDR'];
@$First_name = addslashes($_POST['FirstName']);
@$Surname = addslashes($_POST['Surname']);
@$Email = addslashes($_POST['Email']);
@$Telephone = addslashes($_POST['Telephone']);
@$Query = addslashes($_POST['Query']);
@$Discovery_status = addslashes($_POST['DiscoveryStatus']);

// Validation
if (strlen($First_name) == 0 )
{
header("Location: contact-error.html");
exit;
}

if (strlen($Surname) == 0 )
{
header("Location: contact-error.html");
exit;
}

if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email))
{
header("Location: contact-error.html");
exit;
}

if (strlen($Email) == 0 )
{
header("Location: contact-error.html");
exit;
}

if (strlen($Telephone) == 0 )
{
header("Location: contact-error.html");
exit;
}

if (strlen($Query) == 0 )
{
header("Location: contact-error.html");
exit;
}

if (strlen($Discovery_status) == 0 )
{
header("Location: contact-error.html");
exit;
}

//Sending Email to form owner
$pfw_header = "From: $Email\n"
  . "Reply-To: $Email\n";
$pfw_subject = "Website Contact Enquiry";
$pfw_email_to = "elzet@wsiwebmarketing.co.za";
$pfw_message = "Visitor's IP: $pfw_ip\n"
. "First_name: $First_name\n"
. "Surname: $Surname\n"
. "Email: $Email\n"
. "Telephone: $Telephone\n"
. "Query: $Query\n"
. "Discovery_status: $Discovery_status\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

header("Location: contact-thanks.html");

?>

 

Thanks!

 

EDIT: Please use [code][/code] tags when posting code on the forums!

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.