Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

email not completely populated on submission of form


  • Please log in to reply

#1
Dragon

Dragon

    All Around Computer Nut

  • Retired Staff
  • 2,678 posts
ok, hopefully someone can help me on this issue.

Created a contact form for my website that sends an email to me when a customer enters their email address and puts content in the message body area. The problem I have is that when it sends the email, I get their email address, but not getting the message body that is input in the textarea of the form.

here is my code, it is very simple, but all is get is the "From: $email" no message. it is probably something real easy that I'm missing and maybe another set of eyes can see where my error is.
<?php
  $email = $_GET['email'] ;
  $message = $_GET['message'] ;

  mail( "sales@sixtoed-design.com", "Service Request", "From: $email",
    $message );
  header( "Location: http://www.sixtoed-design.com/thankyou.php" );
?>

  • 0

Advertisements


#2
Nahumi

Nahumi

    Member

  • Member
  • PipPip
  • 15 posts
Hi Dragon,

There's a couple of things going wrong in this script. Firstly you're using the built in mail() function wrong. It should follow the syntax below :

mail(string $to, string $subject, string $message);

So in your case it should be :
mail( "sales@sixtoed-design.com", "Service Request", $message );

The second thing that you need to do is put curly braces in the string to use the $email variable, either that or concatenate the string. I would suggest something like the following :

<?php
  $message = 'From : '.$_GET['email']."\n".$_GET['message'];

  mail( "sales@sixtoed-design.com", "Service Request", $message );
  header( "Location: http://www.sixtoed-design.com/thankyou.php" );
?>

You can probably take it a step further by putting a conditional statement in there to only redirect if the email was sent successfully, so you can do something like this:

<?php
  $message = 'From : '.$_GET['email']."\n".$_GET['message'];

  if(mail( "sales@sixtoed-design.com", "Service Request", $message ))
  {
     header( "Location: http://www.sixtoed-design.com/thankyou.php" );
  }
?>


Hope that helps!
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP