Jump to content

Recommended Posts

I am trying to modify the login script one of the moderators here pointed me to.  It looks like it is working for me but I need it to only run after someone submits the form.  I tried adding isset, but when I did it just post back and does perform the query.

 

Here is my php

 

<?php 
session_start();
require_once('../Connections/prbc.php');

if(isset($_POST['login'])){
$username = '';
$password = '';

if (isset ($_POST['username']) && $_POST['username'] != '')

$username = $_POST['username'];

if(isset ($_POST['password']) && $_POST['password'] != '')

$password = $_POST['password'];

$username = mysql_real_escape_string( $username );
$password = mysql_real_escape_string( $password );

$db_password = md5($password);

mysql_select_db('prbcweb') or die(mysql_error());
$login = mysql_query("SELECT * FROM prbc_user WHERE `user_name` = '$username' AND `user_pass` = '$db_password'");
$row_login = mysql_fetch_array($login);
$row_login_total = mysql_num_rows($login);

if ($row_login_total == 1) {
$_SESSION['MM_Username'] = $row_login['user_name'];
$_SESSION['UID'] = $row_login['user_id'];
header("Location: approver.php");

} elseif ($row_login_total <> 1) {
header("Location: login_2.php");
}
}
?> 

 

And here is my form.  I am not sure what I am doing wrong.  Any assistance would be greatly appreciated.

 

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" name="login" id="login">
              <p>Username: <br>
                <input name="username" type="text" id="username">
</p>
              <p>Password:<br>
                <input name="password" type="password" id="password"> 
</p>
              <p>
                <input type="image" name="submit" src="../images/button_login.gif" width="100" height="26">
</p>
              </form>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.