Jump to content

PHP Contact form help


shontay

Recommended Posts

The code below sits on a page named contact.php  Essentially this contains standard contact details, AS WELL as being the form processor for a Contact form which sits on each page across the website, and the action on this form is action="contact.php?send=yes"  which I hoped would then process the below.  So then the page CAN be a normal content page, although at other times, when actioned contact.php?send=yes, it would then execute the code below, however this doesn't seem to work?  And the server offers no error message to help me resolve this.  Any help would be much appreciated - I am just learning PHP!!  Thank you.    :)

 

<?

 

&sendemail = $_GET["send"];

 

if (&sendemail == "yes")

{

 

  $to = "tonyalawrence@tjldesigns.com , tonyalawrence@hotmail.co.uk";

  $from = "webserver@webheads.co.uk";

  $subject = "Contact Form";

 

  while( list($var,$val) = each($HTTP_POST_VARS) ) {

  $email .= "$var: $val\n";

  }

  mail($to,$subject,$email,"From: $from");

  echo "<p><b>Your contact form message has been successfully sent!</b></p>";

 

}

?>

Link to comment
Share on other sites

Try this...

<?php
# Reports all errors...
error_reporting(E_ALL);
$sendemail = "";
# variables are written with $ sign before them
# need to check the set if they are empty or not 
if (isset($_GET['send']))
{
$sendemail = $_GET['send'];
}
else
{
echo "SEND IS NOT SET <br />";
}

# This code will run if true... 
if ($sendemail)
{
$to = "tonyalawrence@tjldesigns.com , tonyalawrence@hotmail.co.uk";
$from = "webserver@webheads.co.uk";
$subject = "Contact Form";
# where are you getting this variable from.....
# and I think this HTTP_POST_VARS is deprecated...
# which version of PHP you are using... 
while(list($var,$val) = each($HTTP_POST_VARS) ) 
{
$email .= "$var: $val\n";
}

mail($to,$subject,$email,"From: $from");
echo "<p>Your contact form message has been successfully sent!</p>";
}
else 
{
# if there are some errors... this will show
echo "MAIL COULD NOT BE SENT";
}

?>

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.