Jump to content

Form to email


mytutorisfat

Recommended Posts

Hi guys,

 

I have a simple 3 input html form and I found a tutorial that I understand that in theory should send the data from the form to the email address supplied.  It doesnt seem to do anything thought if anyone could point me in the direction of either a better tutorial, a thread where this kind of thing is discussed (I had no luck when I searched) or even spot any problems in the code your help would be appreciated.

 

<?php

 

  $name = $_REQUEST['name'] ;

  $email = $_REQUEST['email'] ;

  $comments = $_REQUEST['comments'] ;

 

  mail( "insert email here", "Query Form Results",

    $comments, "From: $name", "Email: $email" );

  header( "Location: insert url here" );

?>

 

Thanks in advance

 

Mytutorisfat

Link to comment
https://forums.phpfreaks.com/topic/69580-form-to-email/
Share on other sites

Try this (replace red text with whatever is appropriate for your site):

 

<?php

 

$name = $_REQUEST['name'];

$email = $_REQUEST['email'];

$comments = stripslashes($_REQUEST['comments']);

 

$webmaster = 'you @ email.com';

$subject = 'Your Email Subject';

 

mail($webmaster, $subject, $comments, "From: $name <$email>");

 

header("Location: success.php");

 

?>

Link to comment
https://forums.phpfreaks.com/topic/69580-form-to-email/#findComment-349685
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.