Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

email not completely populated on submission of form


  • Please log in to reply

#1
Dragon

Dragon

    All Around Computer Nut

  • Retired Staff
  • 2,682 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( "[email protected]", "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( "[email protected]", "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( "[email protected]", "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( "[email protected]", "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