itjeremiah Posted August 11, 2016 Share Posted August 11, 2016 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> Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted August 11, 2016 Share Posted August 11, 2016 (edited) 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 August 11, 2016 by Jacques1 Quote Link to comment Share on other sites More sharing options...
itjeremiah Posted August 11, 2016 Author Share Posted August 11, 2016 Thanks Guru, I got this as a legacy web project and was not sure on what they were doing in system. With making the update to use names on the form it is up and running. Thanks again Guru. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.