The way I normally run any sort of form page is something like this.  (im
fairly new as well)

Since youre setting $select_sql_two without any conditions, it is setting
the refresh on the page and therefore redirecting you to members.php

You should then place some sort of authentication on the members.php so that
people cant just go there directly.

if(isset($_POST['submit'])) {

.... run sql query

} else {

... display login form


On Jan 8, 2008 9:51 AM, Ben Stones <[EMAIL PROTECTED]> wrote:

> Hello,
> I am having another problem with PHP, and I have tried rectifying the
> problem with each try failing. The problem I have is, whenever I refresh
> the
> page or visit the URL to where the login form is (which is index.php), it
> automatically refreshes to the members page, even if I did not click the
> 'Submit' button (with or without the correct login details, for that
> matter,
> even if I did click the 'Submit' button). I hope someone will be able to
> help me in some way or another to rectify the issue; I have tried seeing
> all
> possibilities of the problem. Once more, I am relatively knew to PHP, so I
> appreciate help towards the right direction.
> Cheers,
> Ben Stones.
> (PS: The PHP code is below)
> $con = mysql_connect("localhost", "ben_test", "removed") or
> die(mysql_error());
> $db = mysql_select_db("ben_test") or die(mysql_error());
> $user = $_POST['username'];
> $pass = $_POST['password'];
> $select_sql = sprintf("SELECT `username` FROM `users` WHERE `username` =
> '$user' AND `password` = '$pass'", mysql_real_escape_string($user),
> mysql_real_escape_string($pass));
> $select_sql_two = mysql_query($select_sql);
> if($select_sql_two) {
> echo 'Redirecting you to members page...';
> echo '[meta http-equiv="refresh" content="5;url=members.php" /]';
> }
> else {
> echo 'Error';
> }
> I've changed the HTML code, by the way, so it doesn't render the HTML code
> in some mail boxes.


Reply via email to