Jump to content

$_GET and $_POST at same time


hustla

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
Link to comment
https://forums.phpfreaks.com/topic/12582-_get-and-_post-at-same-time/
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]
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.

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.