|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
passing variables from one page to another
I'm trying to pass a variable from one page to another when someone clicks on a link. Here is what the link code looks like:
PHP Code:
On the recieving page, viewvuln.php, the variable id is empty. It is never set to whatever $vulnID is. I don't know what I'm doing wrong. I'm using the latest version of PHP and Apach 2.0. Any help is appreciated. Thanks. |
|
#2
|
|||
|
|||
|
Re: passing variables from one page to another
Quote:
I would do like this: PHP Code:
|
|
#3
|
|||
|
|||
|
I've tried that and it still doesn't work. I tried doing the example in Kevin Yank's book, Build Your Own Database Driven Website Using PHP & MySQL. I only have the first 4 chapters, but he has a really good example. It's on page 26 in the .pdf version. You create a HTML file called welcome.html that has:
<a href="welcome.php?name=Kevin"> Hi, I'm Kevin! </a> in it. You create welcome.php with: <?php echo( "Welcome to our Web site, $name!" ); ?> It doesn't work for me. I don't know if Apache or PHP is configured correctly. Other PHP pages work fine. I'm kind of lost and stuck at the same time. Thanks for the help though. |
|
#4
|
|||
|
|||
|
well first off
echo doesn't use () , print does. echo is just echo "text"; , print is print ("text");
Try accessing the $id variable as$_GET[id] or $_REQUEST[id] |
|
#5
|
|||
|
|||
|
To see if your webserver is running proberly you can run the file
phpinfo.php I've made an example of what I think you are trying to do. You can unzip the file and run test.php. It's working on my webserver Good luck. |
|
#6
|
|||
|
|||
|
R.A.F. - I'm sorry, but your example didn't work. I don't know why and I would like to know why.
CrazyTrain - the $_GET[id] worked great. I'd still like to try and figure out why I have to do it this way, but at least I have it working. Thank you all for your help. |
|
#7
|
|||
|
|||
|
Check php.ini
I had this same problem a while ago. By default the register_globals parameter is set to off in php.ini
Set it to on and your variables get passed using the variable name you defined. |
|
#8
|
|||
|
|||
|
Quote:
you can use echo like the following echo ""; echo (""); it doesnt matter Mahanri, if you cant run the phpinfo.php file, there is something wrong with your server. Try reading my article to properlly set up your server. |
|
#9
|
|||
|
|||
|
Let me clarify, I can run the phpinfo file just fine. PHP is working and so is Apache 2.0 I was just having problems passing variables in a url. I tried setting register globals to 'on' and it now works. Thank you all for all of your help.
|
|
#10
|
|||
|
|||
|
hmm ben, print/echo
i got a parse error with echo (""); on the newest version of php. oh well whatever
|
|
#11
|
|||
|
|||
|
Mahanri,
I would suggest you use the $_POST[] / $_GET[] arrays when making your scripts... It's not a big deal for personal use, but if you plan on using your scripts for public use, it's a safer method than using the variable name itself. People may tell you differently, but the fact that it's being used industry-wide must mean something! CrazyTrain, That's weird, I haven't had any problems using () with echo... in fact, I've been using it from day one, and still have no problems. Weird.
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#12
|
|||
|
|||
|
Hey thanks guys. I decided to not turn on register_globals and I was still able to pass my variables just fine. Thanks everyone for all of your help.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > passing variables from one page to another |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|