Problem with the query string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bw
Forum Newbie
Posts: 3
Joined: Tue Aug 26, 2003 3:51 pm

Problem with the query string

Post 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]
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post 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.)
NoReason
Forum Commoner
Posts: 51
Joined: Tue Sep 10, 2002 6:19 pm

Post 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 :)
User avatar
mcsleazycrisps
Forum Newbie
Posts: 6
Joined: Mon Aug 25, 2003 7:12 am
Location: UK

Post by mcsleazycrisps »

use:

Code: Select all

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

Code: Select all

$username = $_getї'username'];
Uppercase the "GET"
bw
Forum Newbie
Posts: 3
Joined: Tue Aug 26, 2003 3:51 pm

Post by bw »

That matters!? Thanks! I never realised. I wondered why everyone else bothered to put it in uppercase. Testing it now.
Post Reply