HTML Form tag ~ PinoySourceCode

Friday, April 25, 2014

HTML Form tag

When creating textbox. labels,textarea , radio button etc. So this necessary to send these control value to the server.

code:

<form name="formanme" action="action.php" method="post">
your input box, textbox etc..
</form>

name  name of the form
action write page name on which page you want to send values. if you take action blank like action=""               then values send on same page.
method  there are two method post and get.
post send value to the server but values not show on URL.
get send value to the server but values show on URL.

Exercise:

<html>
<head>
<title>Exercise</title>
</head>
<body>
<form name="formanme" action="action.php" method="post">
User Name<input name="username" type="text" /><br />
</form>
</body>
</html>

save this php script and name it of index.php.


In this code we use action="action.php" then these control value send to index.php page We reterive these value on index.php page and can print it. Now make another page action.php for reterive these values

====================================
To Retrieve the value of form
For reterive value of Form tag use super global variable like $_GET and $_POST
$_POST['fieldname']         when method is post on form tag.
$_GET['fieldname']           when method is get on form tag.
====================================

This the code to retrieve the value of the form index.php

<html>
<head>
<title>test1</title>
</head>
<body>
<?php

$user=$_POST['username'];
echo $name;

?>

</body>

</html>

Save this script action.php

How to use get method?

a.php

<html>
<head>
<title>exercise1</title>
</head>
<body>
<form name="frm" action="b.php" method="get">
Enter name:<input name="name" type="text"/><br />
<input name="submit" type="submit" value="Submit" />
</form>
</body>
</html>

v.php

<html>
<head>
<title>exercise1</title>
</head>
<body>

<?php

$name=$_GET['name'];
echo $name;

?>
</body>
</html>

isset()

isset is very usefull function when you send value of the form to the server and reterive value.
isset function is use to check variable exists or not exist.

 This return true if variable exists otherwise this return false.

Why we use isset function and benefit of isset function.


When we send value of the server we check $_POST['fieldname'] in isset function. when we click on submit button then this variable exits on page and write code inside this section. if variable exits our code run otherwise code not run.
 if we are not use isset function then code is run without submit the page to another page.

<?php

if(isset($_POST['submit']))
{
echo $_POST['name'];
}

?>
<html>
<head>
<title>Exercise</title>
</head>
<body>
<form name="" action="" method="post">
<input name="name" type="text"><br>
<input name="submit" type="submit" value="Submit" />

</form>
</body>
</html>

Related Posts:

  • Array in PHP Suppose we want to store 100 data item. So we need 100 different variable. So this is very typical work for programmer to manage 100 different variab… Read More
  • PHP Loop Loop execute some statement many times till the condition is fullfill. There are three type or loops. these loops do same work execute statement man… Read More
  • What is PHP? What is PHP?PHP is basically use for web developing dynamic website.Example of dynamic website are facebook.com,google.com etc.About Web DevelopmentW… Read More
  • HTML Form tag When creating textbox. labels,textarea , radio button etc. So this necessary to send these control value to the server.code:<form name="formanme" … Read More
  • If else statement in php if statement is use to check condition if condition is true then body of your code will be  execute.Syntaxif (condition){Code body}Exercise 1:&l… Read More

0 (mga) komento:

Post a Comment

Get updates

Twitter Facebook Google Plus LinkedIn RSS Feed Email

Get Free Updates in Your Email


Enter your email address:

Popular Posts

A visitor from Jung-gu viewed 'PinoySourceCode' 12 hrs 25 mins ago
A visitor from Semnan viewed 'PinoySourceCode' 17 hrs 11 mins ago
A visitor from Dhaka viewed 'PinoySourceCode' 1 day 9 hrs ago
A visitor from Abuja viewed 'PinoySourceCode' 2 days 4 hrs ago
A visitor from Charleston viewed 'Payroll system simple but functional using php ~ P' 2 days 4 hrs ago
A visitor from Dire dawa viewed 'PinoySourceCode' 4 days 1 hr ago
A visitor from Chandigarh viewed 'PinoySourceCode' 4 days 5 hrs ago
A visitor from Abuja viewed 'PinoySourceCode' 6 days ago
A visitor from Accra viewed 'PinoySourceCode' 6 days 13 hrs ago
A visitor from Hyderabad viewed 'Payroll system simple but functional using php ~ P' 11 days 1 hr ago