Author Topic: Form to email  (Read 408 times)

0 Members and 1 Guest are viewing this topic.

Offline mytutorisfatTopic starter

  • Irregular
  • Posts: 5
    • View Profile
Form to email
« on: September 16, 2007, 01:09:25 PM »
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

Offline jesirose

  • Fanatic
  • Posts: 3,819
  • Gender: Female
  • PHP Goddess
    • View Profile
    • Reed's Training Blog
Re: Form to email
« Reply #1 on: September 16, 2007, 01:19:43 PM »
Maybe because it just says insert email here instead of an email
Every time you post "It didn't work" without more explanation, God kills a kitten.
When you post code without code tags, He just teases a puppy. But it's still sad.
What does that php function do? | What does that term mean? | I don't see any errors! | Awesome API Interface
PHP Goddess with Attitude since 2004

Offline mytutorisfatTopic starter

  • Irregular
  • Posts: 5
    • View Profile
Re: Form to email
« Reply #2 on: September 16, 2007, 02:13:59 PM »
argh sorry I should of said I've taken out the actual email and url, I do apologise.  Thanks for the speedy response though :)

Offline TNGuy03

  • Irregular
  • Posts: 12
    • View Profile
Re: Form to email
« Reply #3 on: September 16, 2007, 02:15:19 PM »
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");

?>

Offline mytutorisfatTopic starter

  • Irregular
  • Posts: 5
    • View Profile
Re: Form to email
« Reply #4 on: September 16, 2007, 02:24:28 PM »
Thanks really appreciate it, it's much friendlier here than on other php forums :)

Offline rarebit

  • Devotee
  • Posts: 996
    • View Profile
Re: Form to email
« Reply #5 on: September 16, 2007, 02:27:48 PM »

Offline mytutorisfatTopic starter

  • Irregular
  • Posts: 5
    • View Profile
Re: Form to email
« Reply #6 on: September 16, 2007, 02:35:46 PM »
legend cheers :)