There are two ways to get a variable from a URL in PHP:
When your URL is: http://www.example.com/index.php?id=7 , you can get this id through the command $_GET['id'] or $_REQUEST['id'] and save it in a variable $id .
No need to watch:
// url is www.example.com?id=7 //get id from url via $_GET['id'] command: $id = $_GET['id']
:
//get id from url via $_REQUEST['id'] command: $id = $_REQUEST['id']
the difference is that the variable can be transferred to the file by URL or through the POST method.
if the variable is passed via url, you can get it using $_GET['variable_name'] or $_REQUEST['variable_name'] , but if the variable is sent, you need $_POST['variable_name'] or $_REQUST['variable_name']
So, as you can see, $_REQUEST['variable_name'] can be used in both directions.
PS: Also remember - never do this: $results = mysql_query("SELECT * FROM next WHERE id=$id"); this can lead to hacking MySQL injection and your database.
Try using:
$results = mysql_query("SELECT * FROM next WHERE id='".mysql_real_escape_string($id)."'");
source share