Jump to content


Photo

If action


  • Please log in to reply
6 replies to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 06 March 2006 - 09:51 PM

Hi all

Has anyone ever run into problems using the action query such as

if ($action == "delete" && $id != "")
{

For some reason the web server I am using doesnt understand what the action is and simply ignores it, executing the first sql statement it can find on the page.

Any ideas would be great.

Thanks

Ed



#2 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 06 March 2006 - 09:52 PM

Where are you getting the value of $action from?

#3 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 06 March 2006 - 09:55 PM

[!--quoteo(post=352251:date=Mar 6 2006, 09:52 PM:name=Gaia)--][div class=\'quotetop\']QUOTE(Gaia @ Mar 6 2006, 09:52 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Where are you getting the value of $action from?
[/quote]


Via the form, so the form action might look like

<form id="form" method="post" action="page.php?action=delete">

#4 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 06 March 2006 - 09:56 PM

You'll still have to store the value into the variable.

$action = $_GET['action'];


#5 kenrbnsn

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

Posted 06 March 2006 - 10:43 PM

For this case you would need to use "$_POST['action']"

This has all of the standard problems that indicate that this is a gregister_globals enabled vs. disabled problem.

You should always program your scripts assuming that [a href=\"http://www.php.net/register_globals\" target=\"_blank\"]register_globals[/a] is disabled.

Ken

#6 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 06 March 2006 - 11:02 PM

Are you sure?

page.php?action=delete is the form action, meaning it will go to that url correct?

So, wouldn't you just have to check if ?action=delete is attached to the URL?

#7 kenrbnsn

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

Posted 06 March 2006 - 11:05 PM

Sorry, my mistake -- I saw the action="Post" not the hard coded URL in the action. Yes, $_GET is correct.

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users