New In our Forum
Arc Sin/Cos/Tan by krystirooks
Re: square root by cindye
Math Video Game! Play Fraction Balls!

A+    A−    B  
Home Page
Algebra
Games
Geometry
Interactive
Trigonometry
Forum
Math Jobs




AddThis Social Bookmark Button

PHP Forms: Get and Post

Submitting Forms and retrieving the data

Name:
Password
Copy and Paste the code into a web page , start apache and then type in a username and passoword.

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ;?> ">
Name:<input type="text" name="username"> <br />
Password <input type="password" name="pword"><br />
<input type="submit">
</form>
<?php
echo $_POST['username'] . " and password " . $_POST['pword'] ;
?>

Part II. Write a custom function that performs the log in

function getUname(){
echo $_POST['username'] . " and password " . $_POST['pword'] ;
if($_POST['username'] =='' || $_POST['pword']=='')
echo 'You did not enter a username and password'; } >  if(isset($_POST['username'])&& $_POST['username']!="" && isset($_POST['pword'])&& $_POST['pword']!='' ) getUname();

How to use GET

Click Me
<?php
$url = $_SERVER['PHP_SELF'] .'?username=joe&age=33';
$link= "<a href='$url'>Click Me </a>";

if(isset($_GET['username']) && isset($_GET['age']))
	{
	echo $_GET['username'] . ' is ' .$_GET['age'] ;
	}
else 
	echo $link;
 ?>
One final note, you should always filter variables that come from the outside. It would be very easy for someone to hack our server based on our current code. To help combat this problem use strip_tags();so always use strip_tags($_GET['varable]) around variables that you are taking in from a user. This prevents them from deleting files on your server etc..
Now you're ready to start leanring about sessions
Create a new php page with this and try figuring out what's going on.

Top
Welcome Guest
Please Log in or register
Who's online: 7 Guests, 0 Users :        Please welcome krystirooks, our newest member.
AddThis Social Bookmark Button Page copy protected against web site content infringement by Copyscape