Jump to content

Transferring variables between pages


pistonhead

Recommended Posts

i assume there will be some clicking somewhere on the page, as you said you'd like to pass variables based on a user clicking a button.

 

<form name="passing vars" method="post">

<input type="hidden" value="variable" />

<input type="hidden" value="variable2" />

<input type="button" value="Continue on without filling out any of the HIDDEN fields cause im pr0" />

</form>

 

You are correct. It requires a form. but not one that the user can fill out.

Hi

I was wondering- how can I transfer fixed variables (which are declared in the code, no input from user) between pages, without using the URL (preferably using buttons)?

 

Any help would be greatly appreciated.

 

Thanks

 

use session variables.  just makes sure you have session_start(); at the top of each page else the session variables won't work

 

Page1:

<?php

session_start();

$_SESSION['AnswerToLife'] = 42;

?>

 

Page2:

<?php

session_start();

echo $_SESSION['AnswerToLife']; //it would output '42'

?>

Is there any way I could transfer the variables using clickable pictures?

i.e:

<a href="diagram.php"><img align="left"border="0"
        src="globe/200px-Europe_(orthographic_projection).svg.png" 
        width="150" alt="Europe" height="150" alt="Europe"/></a>

 

Is there any way I could transfer the variables using clickable pictures?

i.e:

<a href="diagram.php"><img align="left"border="0"
        src="globe/200px-Europe_(orthographic_projection).svg.png" 
        width="150" alt="Europe" height="150" alt="Europe"/></a>

 

only way I can think of doing it from clickable pictures is to do it through a url variable, such as <a href="diagram.php?picture=Europe"><img></a>

Is there any way I could transfer the variables using clickable pictures?

i.e:

<a href="diagram.php"><img align="left"border="0"
        src="globe/200px-Europe_(orthographic_projection).svg.png" 
        width="150" alt="Europe" height="150" alt="Europe"/></a>

 

only way I can think of doing it from clickable pictures is to do it through a url variable, such as <a href="diagram.php?picture=Europe"><img></a>

 

Aah, I'm using a specific API key for the linked page. Guess I could send the variables via the URL, and have a conditional statement within the linked page, which selects a certain API key based on the variables passed through.

 

Thanks a lot for your help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.