View Full Version : configurating the "url?variable=value.."feature
Hi, does any one know how to configurate the feature in php where you can pass the variables from one web page to an other via the url? you know the ones thet look like this:
www.mysite.com/page.php?varieble=variavle_value
I'm using IIS 5 under a Windos 2000 server. I did it once but it was like a year a go and all I can remember is that involves the regedit in windows and litle bit in IIS but I'm not sure.
Please I know it's a known topic but I jus re-instaled the php entirely and I just can't find it in any FAQ, so please help me, Thanx
Dylan Leblanc
09-17-2002, 11:11 PM
if your URL has variables defined in it like the example you gave, those become variables in whatever PHP script that URL points to.
http://something.com/page.php?username=Guss&age=10
would give you these variables:
$username with a value of "Guss"
$age with a value of "10"
they are also accessable with
$_GET['username'] and $_GET['age']
usban
09-17-2002, 11:46 PM
If you want to get the variables in the url you have somo different options, but never related with the regedit. When you have a form instead of submitting it using the post method, you have to use the get method. If you do so, you will get all the variables in the URL. Also you can write the url with the variables, for example when doing a window.open.
The syntax is simple:
the name of the page+?+var_name=var_value +&+var_name=var_value ...
Ex: page.php?var1=value1&var2=value2
So it is not any option you have to activate it is only the way you pass the variables to the other page.
Then I just dont get it, as I said i have to re-install php, so my cuestion is more about intall setup than scripting.
I have this page :
<HTML>
<HEAD>
<TITLE>wert</TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
<?php
if(isset($variable)==false)
{?>
function wert()
{
document.location.href = "Prueba.php?variable=123";
}
<?php
}
else
{
?>
function wert()
{
alert('<?php echo($variable);?>');
}
<?php
}
//-->
</SCRIPT><BODY onload="wert()">
</BODY>
</HTML>
but what it does is just a loop insted of give me the alert(), and that's 'cos de variable $varible it is not defined, but how come is that? I just pass it through the url.
My only solution is that since I just reintal php in my server maybe i misconfigurated some how...
P.S. I have just install php with the installer ( the CGI only version, dowloaded from www.php.net.
usban
09-18-2002, 06:23 PM
Try this one, i've tried it and it works with my PHP version. The difference between this one and the other one is that you forget to close the PHP tag after the else. I don't know if you forget it here or in your script but i've tried this and works.
<HTML>
<HEAD>
<TITLE>wert</TITLE>
</HEAD>
<script>
<?php
if(!isset($variable))
{ ?>
function wert()
{
document.location.href = "Prueba.php?variable=123";
}
<?php } else { ?>
function wert()
{
alert('<?php echo $variable ?>');
}
<?php } ?>
</script>
<BODY onload="wert()">
</BODY>
</HTML>
Looking at the names of the variables i guess you are Spanish or speak Spanish, if so "Un saludo". :thumbsup:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.