Sunday, March 23, 2014

POST Method in PHP

First create a webpage that contain a form.


<html>
<head>
<title>Form</title>
</head>
<body>
<center>
<h2>Registration Form</h2>
<form method="POST" action="FormPostMethod2.php">
<table>
<tr>
<td>
Enter Your Name:
</td>
<td>
<input type="text" name="username"/><br/>
</td>
</tr>
<tr>
<td>
Enter Email Id :
</td>
<td>
<input type="text" name="email"/><br/>
</td>
</tr>
<tr>
<td>
Enter Your Password :
</td>
<td>
<input type="password" name="password"/><br/>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="submit" value="Submit" />
</td>
</tr>
</table>
</form>
</center>
</body>
</html>

Now create another page and name it FormPostMethod2.PHP


<html>
<head>
<title>Result of previous page</title>
</head>
<body>
<center>
<h2>Your information is as below</h2>
<table>
<tr>
<td>
User Name :
</td>
<td>
<?php echo $_POST['username']; ?>
</td>
</tr>
<tr>
<td>
Email Id :
</td>
<td>
<?php echo $_POST['email']; ?>
</td>
</tr>
<tr>
<td>
Password :
</td>
<td>
<?php echo $_POST['password']; ?>
</td>
</tr>
</table>
</body>
</html>

First run the 1st file fill up the info and press button. You will redirect to another page that contains your info.


Output :-


1st Screen 


2nd Screen 

No comments:

Post a Comment