Jump to content

Recommended Posts

I have this form sending mail but its not posting the user input details. Any help is greatly appreciated.

 

PHP for sending mail.

<?php
 
$EmailFrom = "email sender";
$EmailTo = "emal recipiant";
$Subject = "Contact";
$Name = Trim(stripslashes($_POST['Name'])); 
$BName = Trim(stripslashes($_POST['BName']));
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 
 
// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}
 
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "BName: ";
$Body .=$BName;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
 
// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
 
// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
 
The form data originates from
<section id="sign-up">
<div class="container">
<div class="row">
<div class="col-lg-12">
<form method="post" action="contactengine.php">
<div class="form-group">
<label for="Name">Name</label>
<input type="text" class="form-control" id="name" placeholder="Name">
</div>
<div class="form-group">
<label for="BName">Business Name</label>
<input type="text" class="form-control" id="BName" placeholder="Business Name">
</div>
<div class="form-group">
<label for="Tel">Phone Number</label>
<input type="number" class="form-control" id="Tel" placeholder="xxx-xxx-xxxx">
</div>
<div class="form-group">
<label for="Email">Email</label>
<input type="email" class="form-control" id="Email" placeholder="Email">
</div>
<div class="form-group">
<label for="Message">Tell us about how we can help.</label>
<textarea class="form-control" id="Message" cols="50" rows="5" placeholder="Write text here..."></textarea>
</div>
 
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
</div>
</section>
 
Link to comment
https://forums.phpfreaks.com/topic/301858-php-mail-send-not-including-form-data/
Share on other sites

None of your form fields has a name. I suggest you comment out the mail() call and simply print the message until you have a basic understanding of PHP.

 

The script in general is very poor and has plenty of security vulnerabilities. You don't even check if anything was submitted at all, which means you get an empty e-mail whenever a human or bot has visited the URL.

 

And what's with the stripslashes()? Magic quotes don't even exist today, so that code you've appearently copied and pasted from somewhere is ancient.

Edited by Jacques1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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