basic php form code example

Example: php form

/* POST */
<?php
/* Receiving form Varibles $_POST */
if(isset($_POST)) {
  echo("Name : ".$_POST["name"]."<br>E-mail :".$_POST["email"]."<br><br>");
}
?>
      
<!-- POST -->   
<html>
<body>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>


</body>
</html>
/* GET */
<?php
/* Receiving form Varibles $_GET */
if(isset($_GET)) {
  echo("Name : ".$_GET["name"]."<br>E-mail :".$_GET["email"]."<br><br>");
}
?>
      
<!-- GET -->   
<html>
<body>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>


</body>
</html>
<!-- POST is the secure way of using forms ! -->

Tags:

Php Example