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
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.

 

 

Link to comment
Share on other sites

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; ?>" />

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.