Passing Strings from HTML to PHP

A

Anonymous

Guest
Hello have what is probably a basic question. Cant seem to get strings to pass from a HTML form to a PHP script. Below is just a snipe

HTML Item
<input id="name" type="text" name="name" placeholder="Your Full Name" />

passes to separate form
$Name = Trim(stripslashes($_POST['name']));

then it is put in the body of an email and sent
$Body = "";
$Body .= "Name: ";
$Body .= $Name;

When it comes to my email all thats there is Name: then the string is missing. Any help would be appreciated. Thank you.
 
Are you listening to a post request on PHP side

Code:
if ($_SERVER['REQUEST_METHOD']=='POST'){
  // get post variable
  $name = "Name " . $_POST["name"];
}

Could be it's not being sent from your HTML side, check console.log if applicable (using JavaScript)
 
Back
Top