Jump to content


Photo

$_GET and $_POST at same time


  • Please log in to reply
5 replies to this topic

#1 hustla

hustla
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 21 June 2006 - 08:26 PM

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

#2 Wildbug

Wildbug
  • Members
  • PipPipPip
  • Advanced Member
  • 1,149 posts

Posted 21 June 2006 - 08:48 PM


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:
<input type="hidden" name="CurrentPage" value="CreateAd">

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

Twice a day my clock works PERFECTLY!  I can't figure out what's wrong with it.

#3 cmgmyr

cmgmyr
  • Members
  • PipPipPip
  • Advanced Member
  • 1,278 posts
  • LocationUSA

Posted 21 June 2006 - 08:53 PM

I would just add the variables as hidden inputs (as above) then you can do whatever you want with them.

#4 hustla

hustla
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 21 June 2006 - 08:54 PM

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.

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 21 June 2006 - 08:54 PM

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

#6 hustla

hustla
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 21 June 2006 - 09:09 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users