If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

form submiting to it's self. if statement not working

the title basicly explains it all. I am making my first script like this, one that submits to its self, but I'm having trouble. it isn't recognizing the beensubmitted. what is wrong with it. I have spent a while on it and I can't figure it out. I really wanna get this right ...I think it would be very usefull

Re: form submiting to it's self. if statement not working

Originally posted by [m] the title basicly explains it all. I am making my first script like this, one that submits to its self, but I'm having trouble. it isn't recognizing the beensubmitted. what is wrong with it. I have spent a while on it and I can't figure it out. I really wanna get this right ...I think it would be very usefull

The reason it was only working once you used the superglobals ($_POST) method on your install is because you probably have PHP > 4.1 and by default in php.ini register_globals is set to off. if you want to write your scripts without using the superglobals, there are two ways you can do it:
1 - edit your php.ini file and set register_globals to on.
2 - you can put the following code at the top of your scripts and your problems will be fixed.
<?php if ( phpversion() >="4.2.0") extract($_POST); ?>

thanks cv98 for the code snippet. I will try it out. I have some old code that needs globals on.

Hi [m],

I think you shouldn't bother with changing the ini file. Globals off is the way to go and will get more common in the future.

On most of my newer pages i make a function that collects all the data form the previous submit and puts it in an array. While it does this it checks that the data is ok (text is text, numerics are numerics etc) stops people busting my sites.

If you do this at the top of the page you know that all the data from the previous page is ok / safe / present. Your code becomes much easier to modify later.

They only tell you its a stupid question when they don't know the answer!

I guess I can't go wrong with useing the $_POST[] thing so I will use that from now on to prevent future bugs

but when it comes to useing other peoples scripts I have decided to change the ini file. I have come across so many annoying bugs becuse they assume that I have set register_globals to on. well that is my complaint and solution.

Instead of changing your ini file, dump the code snippet above (if using post method) into an include file and include it in any page that assumes register_globals on.
Or, if your not sure where your vars are coming from, use the snippet below, also in an include.