Showing posts with label Variable. Show all posts
Showing posts with label Variable. Show all posts

03 May 2005

Php $_GET Variable

php $_GET variable is a predefined php variable name, and values are sent by the HTTP GET method. Get method is not so profound, and the amount of data can be sent is max 100 characters, it displays data (including passwords and usernames) in user's browser address bar, Also makes it vulnerable to SQL injections (Kind of My SQL exploitation done by typing characters in address bar) .


However it is useful, when you want to point to a particular page to retrive data...

<a href="http://www.somesite.com/get_some_data.php?name=sandy>sandy's data</a>
Or collect Data from HTML form

<form name="someform" method="GET" action="toSomePhpFile.php">
Example :

"
myform.html":

<form action="collect.php" method="GET">
Name: <input type="text" name="name" />
Email: <input type="text" name="email" />
<input type="submit" />
</form>

"collect.php"

<? php
echo $_GET["name"] .<br />";
echo $_GET["email"] . "years old! ";
?>

When user clicks submit button, it will look like this in address bar on the browser.

http://www.somesite.com/welcome.php?name=sandy&email=sandy@yahoo.com

02 May 2005

Php $_POST Variable

PGP $_POST variable is a predefined php variable name, and values are sent by the HTTP POST method, exactly like $_GET variable, but data sent from a form with $_POST method is invisible to user.


Example :

"myform.html":

<form action="collect.php" method="POST">
Name: <input type="text" name="name" />
Email: <input type="text" name="email" />
<input type="submit" />
</form>

"collect.php"

<? php
echo $_POST["name"] ."<br />";
echo $_POST["email"] ;
?>

With POST method you can send any amount of data from the HTML form. It is useful when you want to collect... large text, passwords etc.