Jump to content

[SOLVED] Passing variables


Suchy

Recommended Posts

How can I pass a variable ( event id) to a different page when a button is pressed?

The problem is that the events are listed via a loop, and when I use sessions the event session always contains the id of the last event on the list.

 

The only other way I can think of is adding

onclick="window.location.href='login.php?event=<?php echo $id;?> ' 

and then just pulling the id from the url

 

 

 

Is there a different way ??

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/155880-solved-passing-variables/
Share on other sites

Wouldn't it be the same as with Sessions, if by each button I had a hidden filed, ex:

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

and if I pressed on a button for example in the middle of the list, the event_id would always be that one of the last element.

 

 

But on the login.php how would I know what to use if the hidden fields are like:

 

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

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

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

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

I have a events.php page with a list of events (ex. Word class, Powerpoint class ... ), by each I have a register button. What I want is that when someone hits the register button he will be taken to the login.php page, where it will say something like "To register for event $$$$$ please fill out the form".

 

$$$$$ would be the value of the variable that I want to pass from the previous page.

 

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.