Reputation: 13
This might be a basic question, but I cant get a hit on the web for it:
I have a PHP file ready to take input from an html post,
For example:
$var = $_POST["web-page-var"];
Is it possible to open the php file in a browser with the variable statically set already e.g. something like this in the browser`s address bar:
http://my.site/myPHPfile.php_&_web-page-var=some-value
Also, is it possible to include more than one variable?
Upvotes: 0
Views: 1604
Reputation: 4466
This can be done commonly for both post and get using $_REQUEST variable. The code can be follows.
$var = $_REQUEST[web-page-var]
See following url: http://sugunan.net/demo/request.php?web-page-var=your-value&name=your-name&mail=your-mail
Here you can change the value and test it will show the exact value you pass on the url.
The exact code of that url is follows.
<pre>
<?php
print_r($_REQUEST);
?>
if you want any customization let me know i can apply it and send.
Upvotes: 0
Reputation: 46900
That is what GET request method is for, not POST
You can do http://yoursite.com/test.php?a=1&b=2
And access those in PHP like
$a=$_GET["a"];
$b=$_GET["b"];
Once you get that going, you can add some conditional checks to grab the values only if they are present. For example
if(isset($_GET["a"]))
$a=$_GET["a"];
Upvotes: 5
Reputation: 906
Yes yous can use this http://test.com/file.php?a=1&b=2&c=3
for access to calue of variables
$var1=$GET['a']; ,.....
For Use Post You Just Need Advanced Tool With Browser Like Firebug to set post variabe in web file
Upvotes: 0