Reputation: 314
I send data using header in php through this code.
$msg="ljqefnjnf";
header("Location: search.php?sms=".$msg);
and my url is :
localhost/search.php?sms=ljqefnjnf
How to get the sms data in search.php file
Upvotes: 0
Views: 58
Reputation:
Indeed, like @Rahautos said, you can use both $_GET or $_REQUEST global but don't forget that everything which is passed in your url can be "hijacked". You should make tests on what you get from it.
For example, never do that.
<?php
$sms = $_GET['sms'];
unlink($sms . '.php');
?>
You can do, instead of it
<?php
$sms = $_GET['sms'];
$allowed_files = array('conf', 'tmp');
if (in_array($sms, $allowed_files) {
unlink($sms . '.php');
}
?>
Upvotes: 0
Reputation: 1215
The value you seek is in the $_GET
array which holds all the values of arguments passed in through a URL.
In your case you would want to do this:
$message = $_GET['sms'];
But it could be anything in that array. For example if you have this URL search.php?fruit=apple&color=purple
then you would do this:
$fruit = $_GET['fruit'];
$color = $_GET['color'];
You should note though, never blindly trust a user's input without validating it first. You can leave yourself open to attacks such as Injection Attacks
Upvotes: 0
Reputation: 6661
use PHP $_GET
or $_REQUEST
$sms = $_GET['sms'];
$sms = $_REQUEST['sms'];
$_REQUEST
, by default, contains the contents of $_GET
, $_POST
and $_COOKIE
.
Upvotes: 0
Reputation: 11987
use $_GET
$sms = $_GET['sms'];
Just see this for more information
Upvotes: 2