Hopefully a dead simple one...

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 9
Joined: Wed Jan 08, 2003 2:43 pm

Wed Jan 08, 2003 3:01 pm

Hello all,
this is my first post on this forum - it'll probably be the first of many ;)

I'm in my final year at uni, and I have a piece of coursework which requires me to set up and query a MySQL database using php. I have an HTML page which allows the user to either add or update an existing field, depending on whether or not it already exists, which calls a pretty simple php script. I won't go into the coding because there's no problem with that.

The problem is the retrieve part - I can retrieve the fields, but I am supposed to be doing this with another HTML file with an embedded php script (the coursework spec is very specific on this point). Currently, the retrieve is a php script with embedded HTML to format the page correctly. (which doesn't satisfy the criteria of the coursework, but does function correctly.)

What I need to be able to do is run an embedded php script when the 'submit' button is pressed (when the php will query the MySQL database based on the unique key.) The problem is, I can't seem to get the command $PHP_SELF working ( I read on a site somewhere that this should call any embedded php in the current HTML file.) - If I could get this working, my problem would be solved.
Essentially, all I want to know, is what is the correct syntax for calling an embedded php script in this way - is $PHP_SELF the command I should be using, or is there another way of doing it?

I would be very grateful if someone could give me the line I would need to use in HTML.
If I need to give you the code, I can, I was just hoping that this wouldn't be necessary since this is probably a pretty elementary problem.

Any help appreciated.
Sloth out

User avatar
Posts: 826
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Wed Jan 22, 2003 12:45 am

you should not be using $PHP_SELF you should use $_SERVER['PHP_SELF']

$PHP_SELF will only work if register_globals is turned on. Having that turned on it can create sloppy code and make your scripts very vunerable to hacks because if you have an un-initiated variable within your script all one has to do is put it in the URL address bar.. blah I'm going on a tangent now.

what I'm getting at is PHP comes with register_gloabal turned off by default.

Post Reply