Search Results

Search found 1 results on 1 pages for 'user1371500'.

Page 1/1 | 1 

  • PHP Error Form - Leave Contents of Form on Redirect

    - by user1371500
    I have a simple login form in which if an error occurs such as wrong password, I need it to be able to remember the username which was entered. Would I Go about doing this PHP or Javascript as I am not allowed to use JQuery. My current PHP - (Not Including the HTML Form) <?php //MySQl Connection mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("clubresults") or die(mysql_error()); //Initiates New Session - Cookie session_start(); // Start a new session // Get the data passed from the form $username = $_POST['username']; $password = md5($_POST['pass']); // Do some basic sanitizing $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); //Performs SQL Query to retrieve Login Details from DB $sql = "select * from admin_passwords where username = '$username' and password = '$password'"; $result = mysql_query($sql) or die ( mysql_error() ); //Assigns a Variable Count to 0 $count = 0; //Exectues a loop to increment on Successful Login while ($line = mysql_fetch_assoc($result)) { $count++; } //If count is equal to 1 Redirect user to the Members Page and Set Cookie if ($count == 1) { $_SESSION['loggedIn'] = "true"; header("Location: members.php"); // This is wherever you want to redirect the user to } else { //Else Echo that login was a failure. die('Login Failed. <a href=login.php>Click Here to Try Again</a>'); } ?> Any help would be appreciated. Cheers

    Read the article

1