Page 1 of 1

Problem with the query string

Posted: Tue Aug 26, 2003 3:51 pm
by bw
Hey all,

I'm new to PHP (it rocks btw), and I've set up a script to submit a new piece of news when a registered user uses it. The problem is, the next script seems to not read the query string. No matter what I do I can't make it work.

Here's the scripts:

http://geocities.com/benwhitear2000/phpprob.zip

You'll probably have to copy and paste that. Anyway open up submitnews.php and type "Ben" (in that case minus quotes) into the username box. Then submit and see.

Cheers for any help,
Ben[/url]

Posted: Tue Aug 26, 2003 4:01 pm
by Unipus
Well without opening up the zip files at all, I'd guess that you're having the register_globals problem. There's a sticky thread about that, but basically what you need to do is put a declaration of all of your variables in the processing page, like this.


FORM PAGE
There's a text input named 'zip'

PROCESSING PAGE
include this before the variables are used:
$_POST["zip"]

(assuming your form POSTS, if not, use $_GET instead.)

Posted: Tue Aug 26, 2003 4:07 pm
by NoReason
proccessing page:

$Name = $_POST['formElementName'];
$News = $_POST['formElementName'];
etc..

$QueryString = "INSERT INTO table (1,2) values($Name,$News)";

/* executeQueryCode here */

Then you can safely leave register globals off :)

Posted: Tue Aug 26, 2003 4:07 pm
by mcsleazycrisps
use:

Code: Select all

$username = $_GETї'username'];
not

Code: Select all

$username = $_getї'username'];
Uppercase the "GET"

Posted: Tue Aug 26, 2003 4:11 pm
by bw
That matters!? Thanks! I never realised. I wondered why everyone else bothered to put it in uppercase. Testing it now.