Jump to content

So close to getting this php formmail script to work?


ewwatson

Recommended Posts

I'm so close I can taste it! The form gets submitted and emailed to me. The only problem is the email that I get is empty - but at least I get it! So what am I missing - hopefully something little. Here is the form and the php code. Thanks!

 

<form method="post" action="formmail.php">

<label for="name">Name</label>

<input id="name" name="name" class="iehover">

<br>

<label for="email">Email</label>

<input id="email" name="email" class="iehover">

<br>

<label for="subject">Subject</label>

<input id="subject" name="subject" class="iehover">

<br>

<label for="comments">Comments</label>

<textarea id="comments" name="comments" class="iehover"></textarea>

<br>

<input type="submit" name="submit" value="Submit" class="submit iesubmithover">

</form>

 

<?php

$name = $_REQUEST['name'] ;

$email = $_REQUEST['email'] ;

$subject = $_REQUEST['subject'] ;

$comments = $_REQUEST['comments'] ;

 

mail( "[email protected]", "Feedback Form Results",

$message, "From: $email" );

header( "Location: http://www.littleaboutalot.com/thankyou.php" );

?>

 

EDIT - I do get the email in the subject line - or their name from the email I mean. But nothing else.

Try changing

<?php
mail( "[email protected]", "Feedback Form Results",
$message, "From: $email" );
?>

to

<?php
mail( "[email protected]", "Feedback Form Results",
$comments, "From: $email" );
?>

 

$message to $comments

Thanks bro - as you can see I'm somewhat lost with this. OK now I receive the email and the comments. So I am just missing the subject and the name. Here is what we are working with now. It would seem logical to me to just add $subject, $name before $comments. But when I do I no longer get the thank you page or the email - just an error message. Were on the right track though!

 

<?php

$name = $_REQUEST['name'] ;

$email = $_REQUEST['email'] ;

$subject = $_REQUEST['subject'] ;

$comments = $_REQUEST['comments'] ;

 

mail( "[email protected]", "LITTLEABOUTALOT.com Contact Form",

$comments, "From: $email" );

header( "Location: http://www.littleaboutalot.com/thankyou.php" );

?>

Hello, OK - heres my question. Here is my very simple but working php form script.

 

<?php

$name = $_POST['name'] ;

$email = $_POST['email'] ;

$subject = $_POST['subject'] ;

$comments = $_POST['comments'] ;

 

mail( "[email protected]", "mydomain.com Formmail", "Name: $name \n\nSubject: $subject \n\nComments: $comments","From: $email" );

header( "Location: http://www.mydomain.com/thankyou.php" );

?>

 

It outputs this.

 

Name: Eric

 

Subject: Diabetes

 

Comments: So Happy!!

 

It took my a while to get this working so I am quite happy with it. However, I'm sure it's obvious to all of you all that I need to add some security and validation code to it. As I am completely new to php I was wondering if someone would be so kind to help me out. Thanks, take care! By the way it does not need to be anything fancy - just simple and easy for me to understand.

 

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.