Newbie need help with printing form data


I am starting out learning this php. I have made a page called


which has this in it:

First Name:


The PHP page ActionScript.php has this in it

print “Your first name is $name”;

however when i run the script all i am getting on the page is:

Your first name is

the name variable that i type in is not showing?

can anyone help?


First of all you should add this to the beginning of your php scripts while developing, this will give you all errors/warnings so you don’t miss any of those :slight_smile:
[php]ini_set(‘error_reporting’, E_ALL);
ini_set(‘display_errors’, ‘1’);[/php]


  1. you should wrap POST in quotes (method=“POST”)


  1. I would change the name, ActionScript is a scripting language and it’s confusing calling it that ^^
  2. you should not end php execution (?>) if you don’t have to.
  3. you have not set the variable $name

Try this:
[php] <?php
if (!empty($_POST[‘name’])) {
echo htmlentities('Your first name is ’ . $_POST[‘name’], ENT_QUOTES, “UTF-8”);
} else {
echo ‘No name submitted’;

the htmlentities is to prevent xss attacks.

Thank you

Sponsor our Newsletter | Privacy Policy | Terms of Service