Page 1 of 1

Contact form with php [DOESN'T SEND]

Posted: Fri Dec 05, 2008 12:12 am
by saucez
This is an email script for a contact form[it has the form on one page and the code on the next]

1st Page[its a added to the page by a database]

Code: Select all

EMAIL DOESN't WORK at the moment sorry!
<form id="Send" name="Send" method="post" action="send.php">
  <table width="176" border="0" align="center" cellpadding="3" cellspacing="0">
    <tr>
      <td colspan="2"><h1>Contact Us</h1></td>
    </tr>
    <tr>
      <td width="70">Name:</td>
      <td width="106"><label>
        <input type="text" name="name" id="name" tabindex="1" />
      </label></td>
    </tr>
    <tr>
      <td>Email:</td>
      <td><label>
        <input type="text" name="email" id="email" tabindex="2" />
      </label></td>
    </tr>
    <tr>
      <td>Subject:</td>
      <td><select name="subject" id="subject">
        <option value="none~">Please Select a Subject</option>
        <option value="General">General</option>
        <option value="Website Quote">Website Quote</option>
        <option value="Question?">Question?</option>
        <option value="Broken Link?">Broken Link?</option>
        <option value="Bug/Error">Bug/Error</option>
        <option value="Other">Other</option>
      </select>
      </td>
    </tr>
    <tr>
      <td>Message:</td>
      <td><textarea name="message" rows="3" wrap="virtual" id="textfield"></textarea></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><label>
        <input type="submit" name="button" id="button" value="Send Email" tabindex="3" />
      </label></td>
    </tr>
  </table>
</form>
2nd page[send.php]:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 
 
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="i-style.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
<div align="center">
  <?php 
// check for a valid enmail and make sure its not spam
function spamcheck($formfield) 
{
$formfield = filter_var($formfield, FILTER_SANITIZE_EMAIL);
  if(filter_var($formfield, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
}
 
if (isset($_POST["email"]))
{
$mailcheck = spamcheck($_REQUEST['email']);
    if ($mailcheck==FALSE)
        {
        echo "<h2>Invalid input, <a href='i-page.php?pagelink=4'>go back</a></h2>";
        }
    else 
        {
        $email = $_POST["email"];
        $subject = $_POST["subject"];
        $message = $_POST["message"];       
        $name = $_POST["name"];
        
        mail("james@think-designs.net", "Subject: $subject", $message, "From: $email" );
    
        echo '<h2><b>Thank you ' . $name . ' Your email has been sent!</b></h2>';
        }
}
else 
{
    echo "Sorry you didn't completly fill out the email form, please go back and fill it out<br /><a href='i-page.php?pagelink=4'> << Go Back</a>";
 
}
?>
</div>
</body>
</html>
 
THE PROBLEM:

It doesn't send on the send.php page, please help =]

Re: Contact form with php [DOESN'T SEND]

Posted: Fri Dec 05, 2008 12:56 am
by it2051229
try this on your send.php

Code: Select all

 
if(isset($_POST["button"]))
{
     $email = $_POST["email"];
 
     print $email;
}
 

Re: Contact form with php [DOESN'T SEND]

Posted: Fri Dec 05, 2008 3:42 am
by saucez
where do u i put it :S im a newb at php

please post the whole of send.php with the code in it and put comments if possiable =]]
plz

thanks xD

Re: Contact form with php [DOESN'T SEND]

Posted: Fri Dec 05, 2008 3:48 am
by saucez
btw i will explain the error abit better:

i press send, and of coasre it says i have sent it, but when i check my inbox the email will not come for some reason

Re: Contact form with php [DOESN'T SEND]

Posted: Fri Dec 05, 2008 3:57 am
by aceconcepts
Try setting some headers

Re: Contact form with php [DOESN'T SEND]

Posted: Fri Dec 05, 2008 5:30 am
by saucez
I have just added some headers, please help, im pulling my hair out lol. i need to get this finished =]

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 
 
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="i-style.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
<div align="center">
  <?php 
// check for a valid enmail and make sure its not spam
function spamcheck($formfield) 
{
$formfield = filter_var($formfield, FILTER_SANITIZE_EMAIL);
  if(filter_var($formfield, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
}
 
if (isset($_POST["email"]))
{
$mailcheck = spamcheck($_REQUEST['email']);
    if ($mailcheck==FALSE)
        {
        echo "<h2>Invalid input, <a href='i-page.php?pagelink=4'>go back</a></h2>";
        }
    else 
        {
        $to = 'james@think-designs.net';
        $subject = $_POST["subject"];
        $message = $_POST["message"];       
        $name = $_POST["name"];
        $headers = "From: $email";
        
        mail($to, $subject, $message, $headers);
    
        echo '<h2><b>Thank you ' . $name . ' Your email has been sent!</b></h2>';
        }
}
else 
{
    echo "Sorry you didn't completly fill out the email form, please go back and fill it out<br /><a href='i-page.php?pagelink=4'> << Go Back</a>";
 
}
?>
</div>
</body>
</html>
 
please some1 give a good look over it and tell me why it will not send. Like it passes all the If statments and says it has been sent, here if you want to check it out go to http://think-designs.net/ and then press the contact us page and fill it out, it says it has sent, but nothing happens, it used to qwork and then i changed it, but i must of changed somthing i shouldn't of and then stuffed it up

Re: Contact form with php [DOESN'T SEND]

Posted: Fri Dec 05, 2008 5:40 am
by greyhoundcode
Have you checked your spam folder?

Re: Contact form with php [DOESN'T SEND]

Posted: Fri Dec 05, 2008 7:02 am
by saucez
LOL ur right lol, it was in my google apps spam folder, but i use outlook so it didn't get in that spam folder lol.

Just wondering how do u make this email script not appear as spam???

Re: Contact form with php [DOESN'T SEND]

Posted: Fri Dec 05, 2008 7:15 am
by saucez
dw i got it, thanks guys