robdog119
05-02-2006, 03:21 PM
Hi there,
I have a contact form script that someone nicely helped me out with, but I can't get it to work. The user I got it from said that it was tested and worked but that was in PHP 5. I have PHP 4.3.10 and I'm wondering if that is the problem. If someone wouldn't mind taking a look to see what might need to be adjusted, I would appreciate it. It's a pretty clean script, but let me know if there are any questions. Thanks!
<?php
ob_start("ob_gzhandler");
session_start();
//#################################################################################################### ################################################
//#################################################################################################### ################################################
//##
//## These are the the only definable elements in the script.
//## Other than the look and feel of your form, which is at the bottom of the page.
//##
//##
$contactowner = "1"; // "1" = email the site owner ($contactemail)
$contactemail = "address1@email.com"; // Site owners email address
$contactadmin = "address2@email.com"; // Your / Webamster email address
//##
//##
//##
//#################################################################################################### ################################################
//#################################################################################################### ################################################
if (isset($_POST['submit']))
{
$name = $_SESSION['name'] = $_POST['name'];
$address = $_SESSION['address'] = $_POST['address'];
$city = $_SESSION['city'] = $_POST['city'];
$state = $_SESSION['state'] = $_POST['state'];
$zip = $_SESSION['zip'] = $_POST['zip'];
$country = $_SESSION['country'] = $_POST['country'];
$phone = $_SESSION['phone'] = $_POST['phone'];
$email = $_SESSION['email'] = $_POST['email'];
$find = $_SESSION['find'] = addslashes($_POST['find']);
$question = $_SESSION['question'] = addslashes($_POST['question']);
if((isset($_SESSSION['complete'])) and ($_SESSION['complete'] == "True"))
{
header("Location: ". $_SERVER['PHP_SELF'] . "?msg=You have already Submitted this form.");
}
if(empty($_POST['name']) ||
empty($_POST['address']) ||
empty($_POST['city']) ||
empty($_POST['state']) ||
empty($_POST['zip']))
{
header("Location: ". $_SERVER['PHP_SELF'] . "?msg=You must enter all required fields");
}
else
{
if(mysql_query("INSERT INTO `guestbook` (name,
address,
city,
state,
zip,
country,
phone,
email,
find,
question)
VALUES ('$name',
'$address',
'$city',
'$state',
'$zip',
'$country',
'$phone',
'$email',
'$find',
'$question')"))
{
if($contactowner == "1")
{
$to = $contactemail;
$admin = $contactadmin;
$subject = 'Mailing List Submission to the Redmond Bennet Gallery';
$message = "Thank you for joining our mailing list."."\r\n".
"Name : ".$name."\r\n".
"Email : ".$email."\r\n";
$message .= wordwrap($question, 70);
$comment = "The following person has joined your mailing list."."\r\n".
"Name : ".$name."\r\n".
"Email : ".$email."\r\n";
$comment .= wordwrap($question, 70);
$headers = 'From: '. $to . "\r\n" .
'Reply-To: '. $to . "\r\n" .
'Cc:' . "\r\n".
'Bcc: '. $admin . "\r\n".
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $comment, $headers);
mail($email, $subject, $message, $headers);
}
$_SESSION['complete'] = "True";
header("Location: ". $_SERVER['PHP_SELF'] . "?msg=Thank you for submitting this form,<br> Your Details have been stored.");
}
else
{
header("Location: ". $_SERVER['PHP_SELF'] . "?msg=Im sorry there was an error in our database, Please try again.");
}
}
}
?>
I have a contact form script that someone nicely helped me out with, but I can't get it to work. The user I got it from said that it was tested and worked but that was in PHP 5. I have PHP 4.3.10 and I'm wondering if that is the problem. If someone wouldn't mind taking a look to see what might need to be adjusted, I would appreciate it. It's a pretty clean script, but let me know if there are any questions. Thanks!
<?php
ob_start("ob_gzhandler");
session_start();
//#################################################################################################### ################################################
//#################################################################################################### ################################################
//##
//## These are the the only definable elements in the script.
//## Other than the look and feel of your form, which is at the bottom of the page.
//##
//##
$contactowner = "1"; // "1" = email the site owner ($contactemail)
$contactemail = "address1@email.com"; // Site owners email address
$contactadmin = "address2@email.com"; // Your / Webamster email address
//##
//##
//##
//#################################################################################################### ################################################
//#################################################################################################### ################################################
if (isset($_POST['submit']))
{
$name = $_SESSION['name'] = $_POST['name'];
$address = $_SESSION['address'] = $_POST['address'];
$city = $_SESSION['city'] = $_POST['city'];
$state = $_SESSION['state'] = $_POST['state'];
$zip = $_SESSION['zip'] = $_POST['zip'];
$country = $_SESSION['country'] = $_POST['country'];
$phone = $_SESSION['phone'] = $_POST['phone'];
$email = $_SESSION['email'] = $_POST['email'];
$find = $_SESSION['find'] = addslashes($_POST['find']);
$question = $_SESSION['question'] = addslashes($_POST['question']);
if((isset($_SESSSION['complete'])) and ($_SESSION['complete'] == "True"))
{
header("Location: ". $_SERVER['PHP_SELF'] . "?msg=You have already Submitted this form.");
}
if(empty($_POST['name']) ||
empty($_POST['address']) ||
empty($_POST['city']) ||
empty($_POST['state']) ||
empty($_POST['zip']))
{
header("Location: ". $_SERVER['PHP_SELF'] . "?msg=You must enter all required fields");
}
else
{
if(mysql_query("INSERT INTO `guestbook` (name,
address,
city,
state,
zip,
country,
phone,
email,
find,
question)
VALUES ('$name',
'$address',
'$city',
'$state',
'$zip',
'$country',
'$phone',
'$email',
'$find',
'$question')"))
{
if($contactowner == "1")
{
$to = $contactemail;
$admin = $contactadmin;
$subject = 'Mailing List Submission to the Redmond Bennet Gallery';
$message = "Thank you for joining our mailing list."."\r\n".
"Name : ".$name."\r\n".
"Email : ".$email."\r\n";
$message .= wordwrap($question, 70);
$comment = "The following person has joined your mailing list."."\r\n".
"Name : ".$name."\r\n".
"Email : ".$email."\r\n";
$comment .= wordwrap($question, 70);
$headers = 'From: '. $to . "\r\n" .
'Reply-To: '. $to . "\r\n" .
'Cc:' . "\r\n".
'Bcc: '. $admin . "\r\n".
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $comment, $headers);
mail($email, $subject, $message, $headers);
}
$_SESSION['complete'] = "True";
header("Location: ". $_SERVER['PHP_SELF'] . "?msg=Thank you for submitting this form,<br> Your Details have been stored.");
}
else
{
header("Location: ". $_SERVER['PHP_SELF'] . "?msg=Im sorry there was an error in our database, Please try again.");
}
}
}
?>