Jump to content

Recommended Posts

hey everyone, been looking around on these forms for a while now, but never posted

 

ive only been working with php for about a month now, and i am literally pulling my hair out trying to make a simple contact form submit information to me via email using the mail () function

 

i wrote the script from several different sources, it's my own technically, but i followed tutorials in books i have and a tutorial i read on thesitewizard.com about sending mail through forms. I've found a lot of conflicting information and tried my own twists on things to make the page suitable to me. but, the bottom line is that when i strip the code of everything except the mailing action, it still doesnt work.

 

the form:

<form name="contact" method="post" action="contact_submit.php">

<table>

<tr>
<td></td><td><span class="alert">*</span> denotes a required field.</p>
</tr>

<tr>
<td>Name<span class="alert">*</span></td>
<td><input type="text" name="name" /></td>
</tr>

<tr>
<td>E-Mail<span class="alert">*</span></td>
<td><input type="text" name="email" /></td>
</tr>

<tr>
<td>Phone</td>
<td><input type="text" name="phone" /></td>
</tr>

<tr>
<td>Comments<span class="alert">*</span></td>
<td><textarea name="comments" rows="5" cols="#"></textarea></td>
</tr>

<tr>
<td colspan="2" class="center"><input type="submit" value="Submit" class="button"/>
<input type="reset" class="button" /></td>
</tr>

</table>
</form>

 

and the contact_submit.php script:

<?php

  $name  = $_REQUEST['name'] ;
  $email = $_REQUEST['email'] ;
  $phone = $_REQUEST['phone'] ;
  $comments = $_REQUEST['comments'] ; 

  if (!isset($_REQUEST['email'])) {
      header( "Location: contact.php");
  }
  elseif (empty($name) || empty($email) || empty($comments)) {
     require_once('contact_error.inc');
  }
  elseif ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
     require_once('contact_error.inc');
  }
  else {
    mail( "tpl41803@aol.com", "Comment from CARS Contact Form",
      $comments, "From: $name at $email or $phone" );
    
    require_once('contact_complete.inc');

  }  

?>

 

I'm not a professional webdesigner, I've just put together a small site to the best of my ability and I'd appreciate any suggestions at all.

 

thanks

thanks for the reply--

 

i changed the code around a bit, now sending the information to an email address at my domain, and using a different email at my domain for the 4th header -- so it now reads:

 

mail( "email@mydomain.com", "Comment from CARS Contact Form",
      "$comments from $name at $email or $phone", "From: email@mydomain.com" );

 

still no luck with an email going though

 

I'm thinking it might possibly be a problem with the php.ini settings, which I have set as:

 

SMTP = localhost 
sendmail_path = /usr/sbin/sendmail

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.