Indigo Rose Software
  #1  
Old 06-10-2005
ianhull ianhull is offline
Forum Member
 
Join Date: Jul 2004
Posts: 313
asp or php passing variables? not related to AMS but you guys always seem to know :ye

Hi guys,

I am trying to pass variables through my pages it can be asp or php, I have managed to pass "fname" to the next page but I would like page2 which retrieves this information to store it in a hidden field so that I can pass it to another page, any ideas on how to do this?

Thanks guys

Last edited by ianhull; 06-10-2005 at 05:21 AM. Reason: Spelling mistakes
Reply With Quote
  #2  
Old 06-10-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
If it's in a form, that's easy. So for example our original link which leads from page 1 to page 2 might be:

http://www.yoursite.com/page1.php?name=Joe

Then on page 2 you simply add this to your HTML form:

<input type="hidden" name="name" value="<?php echo $name; ?>">

Reply With Quote
  #3  
Old 06-10-2005
rhosk's Avatar
rhosk rhosk is offline
Indigo Rose Customer
 
Join Date: Aug 2003
Location: Maine, USA
Posts: 1,692
Just off the cuff, I think a 'global function' should be able to handle that.
__________________
Regards,

-Ron

Music | Video | Pictures
Reply With Quote
  #4  
Old 06-10-2005
ianhull ianhull is offline
Forum Member
 
Join Date: Jul 2004
Posts: 313
Excellent Corey, Once agin you are the man!

And thanks for that Rhosk, I will look into that.

Thanks again guys.
Reply With Quote
  #5  
Old 06-10-2005
rhosk's Avatar
rhosk rhosk is offline
Indigo Rose Customer
 
Join Date: Aug 2003
Location: Maine, USA
Posts: 1,692
Once again, Corey is quick on the fly. He mentioned that you were "talking web pages". That's what I get for reading/replying too quick. I was thinking too deep. Need more java I guess.
__________________
Regards,

-Ron

Music | Video | Pictures
Reply With Quote
  #6  
Old 06-10-2005
ianhull ianhull is offline
Forum Member
 
Join Date: Jul 2004
Posts: 313
Hi again,

I seem to be having a little trouble with this one.

I can post to the first page which is called welcome.php but I cannot seem to post to welcome2.php as I have an error on line 5

I cannot seem to work it out.

<html>
<body>Welcome <?php echo $_POST["name"]; ?>.<br />
</body>
<form action="welcome2.php" method="POST">
<input type="hidden" name="name" value="<?php echo $name; ?>">
<input type="submit" />
</form>

</html>

Any more help will be greatly appreciated.

Thanks
Reply With Quote
  #7  
Old 06-10-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
Hi. In that case just use:

<input type="hidden" name="name" value="<?php echo $_POST["name"]; ?>">

Reply With Quote
  #8  
Old 06-10-2005
ianhull ianhull is offline
Forum Member
 
Join Date: Jul 2004
Posts: 313


Excellent Corey.

Thanks again.
Reply With Quote
  #9  
Old 06-10-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
Glad to help.
Reply With Quote
  #10  
Old 06-10-2005
ianhull ianhull is offline
Forum Member
 
Join Date: Jul 2004
Posts: 313
Hi again guys,

I just have a little question about php and storing everything globally

I have used a include function on evey page and I am wondering if I enter my name and then retrieve it on page 3, then on page 4 if I have another input box which uses the var name "name" again wil it overwrite the stored var?

Thanks guys, and Ron thanks for your suggestion on globals it does keep everything nice and tidy and it is easier to learn with.
Reply With Quote
  #11  
Old 06-10-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
Yes it will, you can only use each variable name once if you wish the value to hold, or at least you would have to shift the value to another variable/array if you want to keep it but re-use the variable name.

It's the same as in AMS if you replace a variable value, the first one is lost, i.e.:

name = "Joe";
name = "Bob";

Will result in the variable called "name" containing the value "Bob". "Joe" is lost forever unless you shift it somewhere else, i.e.

names={};
name = "Joe";
names[1] = name;
name = "Bob";
names[2] = name;

Would result in the variable "name" containing the value "Bob" but the table "names" containing both "Joe" and "Bob"... Hope that helps.
Reply With Quote
  #12  
Old 06-11-2005
ianhull ianhull is offline
Forum Member
 
Join Date: Jul 2004
Posts: 313
Hey that's excellent Corey,

I did not know I could do that with the tables, You just saved me loads of time again.

Thank you very much

Reply With Quote
  #13  
Old 06-11-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
No problem, for even more check out the free video on "Tables Made Easy" at:

http://www.speedytraining.com/site/cd3.php

Reply With Quote
Reply

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
php question Not related to AMS ianhull Developer's Den 4 06-07-2005 07:23 AM
Help passing screen variables swilk Setup Factory 7.0 Discussion 2 12-06-2004 12:07 PM


All times are GMT -6. The time now is 01:30 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software