change variables by URL


#1

HI EVERYBODY, this is a code for change variables using ragister_globals, $_REQUEST, we have to file

  1. link.php
    [php]
<?php $myfavmovie=urlencode("prison break"); echo ""; echo "Click here to see information about my favorite movie!"; echo ""; ?>

[/php]

  1. movi.php
    [php]
<?php echo 'My favorite movie is'; echo' '; echo $_REQUEST['favmovie']; echo '
'; $movierate=5; echo 'My movie rating for this movie is:'; echo $movierate; ?>

[/php]
this is an example to change one variable by url ($favmovie) , thus the question , if i want to addin onther variable like $movierate ; what i should do ?
thks

Admin Edit: Added [php] tags for readability. Please refer to http://phphelp.com/guidelines.php for Posting Guidelines.


#2

Don’t use register_globals, see the link in my signature on why you shouldn’t.
Don’t use $_REQUEST either, in your case, $_GET would be the best option. Read up on global variables in the PHP manual why you shouldn’t use $_REQUEST.

On your problem: have you searched Google, or another search engine, concerning this problem? If so, which keywords did you use? What did you find? Why did it not suit your needs? What have you tried yourself? What were the results of those attempts and why did they not suit your needs?


#3

Well first I wouldn’t use the $_REQUEST method, I would use the $_GET method.

The GET method will take the variables passed in a URL and assign them to an indexed value in the $_GET array. You can add passed information in the URL by concatenating those details in the URL string. After the File that is going to receive it, you would place a ? (question mark). followed by the variable name an equals sign and it’s value. Subsequent variables (after the first) are concatenated with the & (ampersand) sign.

i.e.
http://mydomain.com/file.php?Variable1=Value1&Variable2=Value2&Variable3=Value3

The above will be processed by the file.php on the domain server for mydomain.com. It will be passed 3 variables. Variable1, Variable2, and Variable3 with the values of Value1, Value2, and Value3 respectively.

Those variables can be accessed by the $_GET array as follows:
$_GET[‘Variable1’], $_GET[‘Variable2’], and $_GET[‘Variable3’] and manipulated within the file.php script.