General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 30th, 2002, 01:17 PM
Mahanri Mahanri is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Illinois
Posts: 10 Mahanri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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:
 $link"<a href='viewvuln.php?id="
$link.= $vulnID
echo 
"$link'>Choice</a> 


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.

Reply With Quote
  #2  
Old September 30th, 2002, 01:39 PM
R.A.F. R.A.F. is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Denmark
Posts: 4 R.A.F. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Re: passing variables from one page to another

Quote:
Originally posted by Mahanri
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:
 $link"<a href='viewvuln.php?id="
$link.= $vulnID
echo 
"$link'>Choice</a> 



I would do like this:

PHP Code:
 $link "<A HREF=\"viewvuln.php?id=$vulnID\">Choice</A>"

Reply With Quote
  #3  
Old September 30th, 2002, 02:52 PM
Mahanri Mahanri is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Illinois
Posts: 10 Mahanri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old September 30th, 2002, 03:18 PM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
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]

Reply With Quote
  #5  
Old September 30th, 2002, 04:08 PM
R.A.F. R.A.F. is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Denmark
Posts: 4 R.A.F. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.
Attached Files
File Type: zip varaibles.zip (462 Bytes, 397 views)

Reply With Quote
  #6  
Old September 30th, 2002, 04:39 PM
Mahanri Mahanri is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Illinois
Posts: 10 Mahanri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #7  
Old September 30th, 2002, 07:10 PM
Kiwi Kiwi is offline
Guru-in-training
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Not where I want to be...yet!
Posts: 38 Kiwi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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.

Reply With Quote
  #8  
Old September 30th, 2002, 08:08 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Quote:
echo doesn't use () , print does. echo is just echo "text"; , print is print ("text");


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.

Reply With Quote
  #9  
Old October 1st, 2002, 08:21 AM
Mahanri Mahanri is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Illinois
Posts: 10 Mahanri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #10  
Old October 1st, 2002, 01:43 PM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
hmm ben, print/echo

i got a parse error with echo (""); on the newest version of php. oh well whatever

Reply With Quote
  #11  
Old October 1st, 2002, 06:29 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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

Reply With Quote
  #12  
Old October 3rd, 2002, 04:29 PM
Mahanri Mahanri is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Illinois
Posts: 10 Mahanri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > passing variables from one page to another


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT