Tuesday, February 1, 2011

Setting ACTION-PHP

Assalamualaikum n selamat sejahtera

As we learn from previous post,we learn to submit our form data to the same PHP page.So,this post will show to you on how to submit on the other page.First thing first,we create another file,this one,we name it SecondForm.php..ok?hehe.Here is the code:

<html>
<head>
<title>THE SECOND FORM</title>
</head>
<body>

<Form name ="formOne" Method ="POST" Action ="submit2.php">
<INPUT TYPE = "TEXT" VALUE ="Username" Name ="Username">
<INPUT TYPE = "Submit" Name = "SubmitOne" VALUE = "Login">

</FORM>
</body>
</html>


Notice the bold and blue text,so for this post,we will apply the function of the ACTION.To know more on ACTION?so,make another file named: submit2.php.Yea,guess what,after we submit the form,we will send the data to submit2.php. Here is the code:

<?PHP
$username = $_POST['Username'];
if ($username == "master") {
print ("Welcome back, friend!");
}
else {
print ("You're not a member");
}

?>

So,we got two file: SecondForm.php and submit2.php


N/NOTE:try it!

No comments:

Post a Comment