Jump to content

button and value to handoff to another PHP page


xjermx

Recommended Posts

I have a page with some buttons on it, currently using html <submit> that I am using to link to another PHP page.

 

I am interested in having a set of functions represented on page 1 by buttons.  In this case, something like "Create a new message", "Read messages for me", "View messages that I have sent".  I want each of these functions to be supported on page 2.  I'm aware that I can likely do this with functions and switch or if statements, but my question is this:

 

What is the best case recommendation for implementing the buttons on page 1 and then getting the $whichaction variable or value over to page 2 so that page knows which function to execute?

 

Link to comment
Share on other sites

Well, you could either hand the $_POST value into a session variable and have it redirect you to the next page, and have that page take action depending on the session variable.

 

Or, you could just use a $_GET variable set to the $_POST value.

 

Hope this helps :)

Link to comment
Share on other sites

<input type="submit" name="calculate" value="add">
<input type="submit" name="calculate" value="subtract">
<input type="submit" name="calculate" value="multiply">

My favorite method is something like this... same name and type but different values.

Then just check the isset() for calculate and if it exists check its value then do whatever based on the value.

 

EDIT:

Good reference: http://articles.techrepublic.com.com/5100-10878_11-5242116.html

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.