Log in

View Full Version : PHP Login "This page contains POST DATA..."



Moshambi
08-28-2008, 07:58 PM
Ok so I have a login form on my homepage where users can login (obviously), but when I refresh the page it pops up with the "This page contains POST DATA.." dialog...I dont want this to happen though. Is there any way to fix this or am I going about this wrong in the first place? Help is always appreciated, thanks!

EDIT: Also if I may ask, where is a good/correct place to put session_destroy(); ?

volunteeer
08-30-2008, 08:11 PM
This is normal that when you refresh webpage containing POST data your browser asks you "This page contains POST DATA.. Do you want...". I don't think you can change this behaviour.

techietim
08-30-2008, 08:29 PM
You can work around this by redirecting the user to the page again after the form has been submitted.

Moshambi
08-30-2008, 08:52 PM
so techietim how would I go about that...say just use like a filler page? Kinda like how on some sites it says "You are Now Logged In please wait for you browser to redirect you" or something like that. Because I would like them to be on the same page just logged in...

Thanks for your help!

jackbenimble4
08-30-2008, 08:59 PM
Once you have validated the user's credentials, and updated the sessions you'd set a redirection header for the same page before any html is outputted.



<?php

// check user credentials

// log them in

// they're now logged in, let's redirect them to this same page
header("Location: http://example.com/myloginpage.php");

?>


The better solution would probably to separate the script into two different pages. This depends on the setup though. I don't know enough about your situation to recommend one thing over another.