Jump to content

Archived

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

hustla

$_GET and $_POST at same time

Recommended Posts

OK guys at one point i hade this working but for the past 3 hours i can't get it to work anymore.
What i want to do is simply have a form where the action url has variables that get stored in the $_GET global but the form data in the $_POST. for example

<form action="?MyAds&CurrentPage=CreateAd" method="post" enctype="multipart/form-data">

i want to access CurrentPage and MyAds in the $_GET but on sumbit the $_GET is not being set its null and i have no idea why please help me out here im using php5. The post data on the form is indeed being saved which is how i want it but im using the $_GET for site navagation.

Thanks

Share this post


Link to post
Share on other sites

I'm not sure how PHP deals with those GET variables in a POST action form, but I can suggest a slightly different approach.

If you put your extra GET variables into the form using "hidden" inputs:[code]<input type="hidden" name="CurrentPage" value="CreateAd">[/code]

Then you can use PHP's superglobal, $_REQUEST, to check for those variables regardless of whether they've been set via GET or POST.[code]I.e.,
if ($_REQUEST['CurrentPage'] == 'CreateAd') ....; // etc[/code]

Share this post


Link to post
Share on other sites
I would just add the variables as hidden inputs (as above) then you can do whatever you want with them.

Share this post


Link to post
Share on other sites
Yea i considered that but its killing me why this is not working i tyed the same method on a different page and it worked. let me know if you guys come up with any other ideas i might have to use your suggestion.

Share this post


Link to post
Share on other sites
GET & POST work fine together, you just have to remember to use $_GET for the ones on the URL and $_POST for the others.

Ken

Share this post


Link to post
Share on other sites
ok i think i might know what the problem is. I have two forms inside the page how do i map the button to the appriate form action

ok i finnaly solved the problem ... this site im making is getting big so im seperating each part of the web page and incudeing them based on parameters. What was casusing the problem was that i had a form inside another form therefore on a submit it took the first forms action instead of the secounds action url. Thanks guys im so glad this damn problem is over it was killing me.

Share this post


Link to post
Share on other sites

×

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.