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
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]
Link to comment
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.
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.