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!
I reused this code from a project I had done in the past, but now I cannot get the script to call secure.html.php. It always sees the switch as set and I am not sure why. I get the feeling I missing something really small. Can anyone see why?
Well if the form method = post then it executes the 'POST' case. Since the include is not in the 'POST' case, why would it include?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
What is happening is whether or not there is information posted from the form, it always executes what's under the 'POST' case in the switch. It won't under any circumstances call secure.html.php which should be called when there is no posted data.
Hope that is a little clearer... sorry for any confusion.
michaelk46 wrote:What is happening is whether or not there is information posted from the form, it always executes what's under the 'POST' case in the switch. It won't under any circumstances call secure.html.php which should be called when there is no posted data.
Hope that is a little clearer... sorry for any confusion.
It does not matter if there is information inside the form being posted. You are making a post request, regardless. See AbraCadaver's post above.
michaelk46 wrote:What is happening is whether or not there is information posted from the form, it always executes what's under the 'POST' case in the switch. It won't under any circumstances call secure.html.php which should be called when there is no posted data.
Hope that is a little clearer... sorry for any confusion.
It does not matter if there is information inside the form being posted. You are making a post request, regardless. See AbraCadaver's post above.
Yes, $_SERVER['REQUEST_METHOD'] will always be post from the form, even if there is no data. You probably want to use something like:
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
michaelk46 wrote:Actually, I ended up going with this...
if ($_SERVER['REQUEST_METHOD'] == 'POST') and it's working pretty good.
I saw on another forum that someone thought using if ($_POST) was better than using what is posted above. Is that true? If so why?
They are two separate things. If you have a form with method="post", then $_SERVER['REQUEST_METHOD'] will always be equal to 'POST' even if all fields are left blank. I wasn't thinking clearly in my last post, but $_POST will be empty if all fields are empty including the submit button, so it may be of little use because the submit button usually has a value.
It really depends upon what you want to know. Do you want to know if a post operation took place or if all the posted fields are not empty???
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
I wanted to know whether or not a post took place but thanks for showing me the if ($_POST). That will help me later with another part of the project I am working on currently.