Passing Strings from HTML to PHP

the mail() function

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Feb 18, 2017 10:07 pm

Mon Mar 13, 2017 10:58 am

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

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

User avatar
php-forum Fan User
php-forum Fan User
Posts: 845
Joined: Mon Feb 22, 2016 5:52 pm

Wed Mar 15, 2017 11:34 am

Do you have a full form, or just the input field?

New php-forum User
New php-forum User
Posts: 4
Joined: Mon Jun 05, 2017 7:17 pm

Mon Jun 05, 2017 10:26 pm

Are you listening to a post request on PHP side

Code: Select all

  // 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)
I'm not an expert

Post Reply