Access form data as variable in PHP

Description

The following code shows how to access form data as variable.

Example


//index.htm//  w ww.j a  v  a2 s. c om
<html>
<body>
<form action="index.php" method="post">
Your Name:<br>
<input type="text" name="name" size="20" maxlength="20" value=""><br>
Your Email:<br>
<input type="text" name="email" size="20" maxlength="40" value=""><br>
<input type="submit" value="go!">
</form>
</body>
</html>


//index.php
<html>
<head>
<title></title>
</head>
<body>
<?
    print "Hi, $name!. Your email address is $email";
?>
</body>
</html>

The code above generates the following result.

Access form data as variable in PHP




















Home »
  PHP Tutorial »
    Form »




PHP Form
Form Demo