POST method in php form

Hi friends,in this post I am sharing about simple php forms using post method .

post method php form

 

If you have not known  how to use php in  wamp server  ,see in below link

Learn php in wamp server

  • Create a hello.php file in www directory in wamp server .
  • Copy and paste the below code in hello.php

<html>
<head>
    <title>PHP sript</title>
</head>
<body>
<form action="hello.php" method="post">
Name: <input type="text" name="name">
<input type="submit">
</form>
Welcome <?php echo $_POST["name"]; ?><br>
</body>
</html>

  • Open your wamp server and check local host working on browser.In browser type localhost.hello.php .Now you get the output like below,

php form

  • In the above image you can see notice.It’s not an error,just like warning,In further posts we will explain this.

submit value

  • Enter name in blank field and click submit like above.
  • Now it displays name like below,

output php form

That’s all you have made initial step in php form

Another sample,copy and paste below code in hello.php file

<html>
<head>
    <title>PHP sript</title>
</head>
<body>
<form action="hello.php" method="post">
Name: <input type="text" name="name">
Age: <input type="text" name="age">
Class:<input type="text" name="class">
<input type="submit">
</form>
Welcome <?php echo $_POST["name"]; ?><br>
Your age is <?php echo $_POST["age"]; ?><br>
Studying <?php echo $_POST["class"]; ?> standard
</body>
</html>

  • You get like below and enter name,age,standard.,

php form2

  • Now you get output like below,

php output form2

There are more things in php forms we will update in next posts.

Print Friendly and PDF
SHARE

About me

Hi. I am interested in blogging.And sometimes play with webdesign,web development,domain sale,designing logo and more.

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment

Pages