PHP Programming

Hands On No. 15 : Working with GET Method in PHP

Working with GET Method in PHP

Code to display username on the screen

                              

<?php

if( $_GET["uname"] || $_GET["id"] ) {

if (preg_match("/[^A-Za-z'-]/",$_GET['uname'] )) {

die ("invalid name and name should be alpha");

}

echo "Welcome to ". $_GET['uname']. "<br />";

echo "Your identification number is: ". $_GET['id'];

exit();

}

?>

<html>
<body>
<form action = "<?php $_PHP_SELF ?>" method = "get">

University Name: <input type = "text" name = "uname" />

ID: <input type = "text" name = "id" />

<input type = "submit" />

</form>
</body>

</html>