6 Replies - 1024 Views - Last Post: 02 August 2009 - 03:05 PM Rate Topic: -----

#1 FliP1992  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 200
  • Joined: 14-June 07

PHP Form Action

Posted 02 August 2009 - 01:51 PM

I've hit a problem trying to us GET in a form
<form action='index.php?page=crime&ID={$_GET['ID']}' method='get'>


but when i submit the form it just to:
index.php?ID=1

and misses out the other part of the url
If it try it without the {$_GET['ID']} i get the same result, It seems to just stop at the index.php

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: PHP Form Action

#2 ShaneK  Icon User is offline

  • require_once("brain.php"); //Fatal error :/
  • member icon

Reputation: 240
  • View blog
  • Posts: 1,224
  • Joined: 10-May 09

Re: PHP Form Action

Posted 02 August 2009 - 02:07 PM

Can you post all of the form code please?

Yours,
Shane~
Was This Post Helpful? 0
  • +
  • -

#3 sparkart  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 113
  • View blog
  • Posts: 691
  • Joined: 16-February 09

Re: PHP Form Action

Posted 02 August 2009 - 02:09 PM

I am not an expert at PHP so I could be wrong.

But I thought get passes the parameters through the URL.

action='file_to_process'
Was This Post Helpful? 0
  • +
  • -

#4 FliP1992  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 200
  • Joined: 14-June 07

Re: PHP Form Action

Posted 02 August 2009 - 02:14 PM

Thats what i was thinking as theres somthing taking just that part out.. is there anyway to get around this?
Was This Post Helpful? 0
  • +
  • -

#5 ShaneK  Icon User is offline

  • require_once("brain.php"); //Fatal error :/
  • member icon

Reputation: 240
  • View blog
  • Posts: 1,224
  • Joined: 10-May 09

Re: PHP Form Action

Posted 02 August 2009 - 02:18 PM

Yeah, use POST...
<form action='index.php?page=crime&ID={$_GET['ID']}' method='POST'>


It's a lot like GET, except in PHP you refer to it as $_POST['Name']...

Yours,
Shane~

This post has been edited by ShaneK: 02 August 2009 - 02:19 PM

Was This Post Helpful? 0
  • +
  • -

#6 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: PHP Form Action

Posted 02 August 2009 - 02:26 PM

View PostFliP1992, on 2 Aug, 2009 - 04:14 PM, said:

Thats what i was thinking as theres somthing taking just that part out.. is there anyway to get around this?


Form action should just be index.php. The fact that you're using the GET method will generate the rest.

Your form must include an input object named page for that portion of the URL to be generated. The downside though to using $_GET is that, with it being in the URL, people can manipulate the data, so you have to take extra precautions to ensure security can't be compromised.
Was This Post Helpful? 0
  • +
  • -

#7 ShaneK  Icon User is offline

  • require_once("brain.php"); //Fatal error :/
  • member icon

Reputation: 240
  • View blog
  • Posts: 1,224
  • Joined: 10-May 09

Re: PHP Form Action

Posted 02 August 2009 - 03:05 PM

View PostValek, on 2 Aug, 2009 - 02:26 PM, said:

Your form must include an input object named page for that portion of the URL to be generated. The downside though to using $_GET is that, with it being in the URL, people can manipulate the data, so you have to take extra precautions to ensure security can't be compromised.


You can just as easily edit POST data. You don't take "extra" precautions, you take normal precautions.

By the way, if the page your sending the data to requires the GET data like that, then it's fine to do it like you did. I do something similar to post comments on an image gallery I made recently.

Yours,
Shane~

This post has been edited by ShaneK: 02 August 2009 - 03:07 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1