the $_GET['name'] in php

(1/3) > >>

xhunter:
Hello,
I want to know how do I use the $_GET['something'] in php

Here is my code :
This is for the menu.php
Code:

<html><body>
<form method="post" action="process.php">
Order:</br>
<input type="checkbox" name="Order" value="Paint">Paint<br/>
<input type="checkbox" name="Order" value="Brushes">Brushes</br>
Quantity:<input type="text" name="Quantity">
<input type="submit" value="add to chart">
</body></html>

this is for the process.php
Code:

<?php
$order=$_GET['Order'];
$number=$_GET['Quantity'];
echo " Your will be receiving".$number." ".$order."from nogdus.com soon,thank you";
?>

when I replace the $_POST instead of $_GET it works fine !
then how do we use the $_GET
Thank you

Richard Marks:
You need to tell your form to use GET style queries.
Code:

<form method="get" action="process.php">


Also, a tip for the echo statement.

Code:

echo 'You will be receiving x', $number, ' of ', $order, ' from nogdus.com soon, thank you.';


As you see above, you can chain arguments to be output by the echo command using the comma.
And static strings should always be in single quotes. (They are faster)

xhunter:
Ah !
Thanks for the help Richard
nice tip,I don't know this one ;)



cheers,

Richard Marks:
No problem.

Just something to know though; You really should be using POST http queries instead of GET.

GET is insecure, and opens the door to many bad things if used improperly.

GET values should never be used directly, and should always be tested against valid values to ensure that the data is not going to cause problems.

Never use

Code:

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


use

Code:

$g = ''; // start with nothing
if (IsSet($_GET['g']))
{
    if ($_GET['g'] == $valid_g)
    {
        $g = htmlentities($_GET['g']);
    }
}

echo $g;


Its much safer.
Better would be to use regular expressions for validation, but you can avoid learning that for now.
Just make a note that you NEED to learn them at some point.

tcaudilllg:
What about $_REQUEST[]?

Navigation

[0] Message Index

[#] Next page