Jump to content

Simple Form Help


nickb_53

Recommended Posts

I cant figure this form out, Im New to PHP

 

the form has 3 fields (name, email, and message)

I can get the form to work but cant include the name field in the results?

Ive tried to add  , $name after the $message, But this results in the from email address coming through incorrect?

sorry Im new to PHP. any help be gratefull

_________________________________________________________________________________________________

 

<form id="form1" action="sendmail3.php" method="post" enctype="multipart/form-data" name="form1">

 

Name:<div class="form">

         <input name="name" type="text" size="30">

 

E-Mail:</div>

        <div class="form">

           <input name="email" type="text" value="" size="30">

Message:</div>

          <textarea name="message" cols="33" rows="11"></textarea>

 

a href="#" class="link" onClick="document.getElementById('form1').reset()">clear</a><a href="#" class="link" onClick="document.getElementById('form1').submit()">send</a><br>

</form>

________________________________________________________________________________________________________

 

 

the sendmail3.php

 

 

<?

 

$email = $_POST['email'] ;

$message = $_POST['message'] ;

$name = $_POST['name'] ;

 

mail( "nickb53@tiscali.co.uk", "Contact Request", $message, "From: $email" );

print "Congratulations your email has been sent";

?>

 

Link to comment
Share on other sites

either before or after the Message

Ive tried

mail( "nickb53@tiscali.co.uk", "Contact Request", $message, $name, "From: $email" );

 

this causes the email adress to come trough as server adress, not the sender

is my code incorrect?

Link to comment
Share on other sites

try replacing your sendmail2.php with...

<?php
$to = "nickb53@tiscali.co.uk";
$subject = "Contact Request";
$message = $_POST['message'];
$email= $_POST['email'];
$headers = 'From: $email' . "\r\n"; //<-- not sure if this one is completely right

mail($to, $subject, $message, $headers);
?>

 

hopefully that'll fix ur problem

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.