Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 25th, 2008, 11:50 PM   #1
MrMan9879
Programmer
 
MrMan9879's Avatar
 
Join Date: Sep 2005
Location: Nanaimo, BC, Canada
Posts: 97
Rep Power: 0 MrMan9879 is an unknown quantity at this point
Send a message via MSN to MrMan9879
Sending Forms with GET variables from other forms

Hi guys, I have another question... this time about using forms and the $_GET method.

Basically, for the website I'm building I have a news posting system, and I want to have a page where you can edit the posts. When you go to the editing page, I want to be able to order it by ID or title name.

My editing page is on my index.php, but I have a few pages on there, and I use a $_GET variable to get to them.
ie. index.php?act=post index.php?act=edit

I'm also using a $_GET variable for ordering the news articles to edit/delete
ie. index.php?act=edit&sort=newsdesc

But, I'm wondering how I can send the form that holds the sort variable to the page and also keep the act variable. I thought it might be as simple as this:

<form action="index.php?act=edit" method="get">
                <input type="radio" name="sort" value="newsdesc" />
           </form>

But, all this does is send it to index.php.

Does anyone know how I could accomplish this?
MrMan9879 is offline   Reply With Quote
Old Feb 26th, 2008, 8:43 AM   #2
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
Re: Sending Forms with GET variables from other forms

Quote:
Originally Posted by MrMan9879 View Post
<form action="index.php?act=edit" method="get">
<input type="radio" name="sort" value="newsdesc" />
 </form>
You could use a hidden field set it's value to the action, or just stick it in the $_SESSION array.

<form action="index.php?act=edit" method="get">
                <input type="radio" name="sort" value="newsdesc" />
                 <input type="hidden" name="action" value="<?php print $_GET['action']" />
           </form>
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Feb 26th, 2008, 8:56 AM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Re: Sending Forms with GET variables from other forms

Little tip: never just chuck out unescaped user input. Try this:
<input type="hidden" name="action" value="<?php echo htmlspecialchars($_GET['action']) ?>" />
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 26th, 2008, 11:04 PM   #4
MrMan9879
Programmer
 
MrMan9879's Avatar
 
Join Date: Sep 2005
Location: Nanaimo, BC, Canada
Posts: 97
Rep Power: 0 MrMan9879 is an unknown quantity at this point
Send a message via MSN to MrMan9879
Re: Sending Forms with GET variables from other forms

Wow, I must have been tired last night... I'm not sure why that didn't occur to me.

Thanks for your help again, Ooble.
MrMan9879 is offline   Reply With Quote
Old Feb 27th, 2008, 5:47 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Re: Sending Forms with GET variables from other forms

Methinks it was kruptof that gave you the solution. I just expanded on it a little.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 27th, 2008, 10:11 PM   #6
MrMan9879
Programmer
 
MrMan9879's Avatar
 
Join Date: Sep 2005
Location: Nanaimo, BC, Canada
Posts: 97
Rep Power: 0 MrMan9879 is an unknown quantity at this point
Send a message via MSN to MrMan9879
Re: Sending Forms with GET variables from other forms

Oh sorry, Kruptof I just read the bottom post and for some reason assumed it was Ooble both times.
MrMan9879 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Winsock: specified sending jayme C++ 2 Dec 5th, 2007 7:24 PM
dealing with multiple forms Booooze C# 12 May 12th, 2006 6:12 PM
Variables between forms nez C# 4 Mar 7th, 2006 2:24 PM
Variables coldDeath Python 4 Aug 9th, 2005 12:35 PM
Is it possible for me using session variables into a class? see07 C# 1 Mar 9th, 2005 6:32 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:34 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC