Jump to content

Can somebody please help? Email Form


chubba

Recommended Posts

Hi Guys

 

I am new to this, i have having trouble getting an email form to work. I need to work out the code that will go in the contact.php. The form code on the contact us page is:

 

<form name="form" action="contact.php" method="get"> 

<div class="box_left column">

<div class="tt"><input type="text" value="Your Name:" /></div>

<div class="tt"><input type="text" value="Your Fax:" /></div>

<div class="tt"><input type="text" value="Your Phone:" /></div>

<input type="text" value="Your E-mail:" />

</div>

<div class="box_right column">

<textarea cols="3" rows="3">Your Message:</textarea>

<strong style="margin:0 21px 0 102px;"><a href="javascript:form.reset();"><strong>clear</strong></a>  <a href="javascript:form.submit();"><strong>send</strong></a> </div>

<div class="clear"></div>

</form>

 

I just need the information  to get sent to outlook, With The sender email as in From: Persons name in subject: and Fax and Phone numbers and message to make up the message.

 

Can anyone please advise?

 

Link to comment
Share on other sites

Well short of laying it out for you.. I notice one thing you deffinately need is name variables for your input fields...

 

you have

<input type="text" value="Your Name:" />

 

you should have

<input type="text" value="Your Name:" name="name" />

 

as far as the contact.php there after if you want to do it yourself I would advise you to goto php.net and look into $_POST $_Get functions as well as the mail() function..

 

otherwise I might be able to help you if you like..

Link to comment
Share on other sites

Naming your variable is essential, then it is as simple as this:

 

<?

//send the email

$mail_sent = @mail( $to, $subject, $message, $headers );

//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"

echo $mail_sent ? "Mail sent" : "Mail failed";

?>

Link to comment
Share on other sites

its that simple yes with the mail function but I would personally beef it up a notch with distinct headers an what not. Just in attempts to avoid it from being kicked back by some systems, and out of bulk folders on others, a few other random reasons.. but thats just me, its not necessary 100% to have all this but its nice..

 

something like:

(which this is a sample that would work for sending HTML based emails but you could strip out the HTML elements from the message part and just do plain ol text if you like)..

 

$to  = 'monkeytooth@gmail.com' . ', '; // note the comma
$to .= 'soulzllc@gmail.com';

// subject
$subject = '[MT Contact] ' . $_POST["T3"];

// message
$message = '
<html>
<head>
  <title>[MT Contact] $_POST["T3"]</title>
</head>
<body>
  <table>
    <tr>
      <th>Data Type</th><th>Input Data</th>
    </tr>
    <tr>
      <td>Name:</td><td>' . $_POST["T1"] . '</td>
    </tr>
    <tr>
      <td>Company:</td><td>' . $_POST["T2"] . '</td>
    </tr>
    <tr>
      <td>Email:</td><td>' . $_POST["T3"] . '</td>
    </tr>
  </table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: Contact <contact@monkeytooth.net>' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);

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.