Jump to content

Modification of exsiting login code


napa169

Recommended Posts

Hello.

My site works, but needs tweaking. I can do the simple stuff, but don't know how to do this.

Index.php has error checking code at the top for when the user logs in. I would like to change this so that the login script would call a login page for error checking. I could then add other php scripts to the front page without problems. (And edit them without running into php issues.) I just have to know how to make the call action work. I have a few other pages I would like to do this with too. Any and all help is greatly appreciated.

This is the first part of the code at the top of the index.php file.

<? include ("includes/config.php"); ?>
<?
if ($_POST["action"] == "login") {

require ("includes/conn.php");
$query = "SELECT * FROM `users` WHERE `user_Username` = '$_POST[user_Username]' AND `user_Password` = '$_POST[user_Password]' AND `user_Status` = '1'";
$result = mysql_query ($query);

if (mysql_num_rows($result) > 0)
{
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$continue = "true";
$_SESSION["ses_logged"] = "1";
$_SESSION["ses_myID"] = $row["user_ID"];
header ("location: welcome.php");
exit();
}
} else {
$continue = "false";
$error = "Invalid Login! Please try again.";
}
mysql_free_result($result);
mysql_close();

}
?>

The login script. (With some extra html code deleted)

<table width="245" border="0" align="right" cellpadding="0" cellspacing="0">
  <form method="post" action="invalid_login.php">
    <input type="hidden" name="action" value="login">
    <tr>
      <td colspan="4" class="title"></td>
    </tr>
    <? if ($error) { echo "<tr><td colspan=2 class=required>". $error ."</td></tr>"; } ?>

      <td colspan="2"><input type="text" name="user_Username"></td>
    </tr>
    <tr>
      <td align="right"><img src="images/password.gif" alt="password" width="72" height="25"></td>
      <td colspan="2"><input type="password" name="user_Password"></td>
    </tr>
    <tr>
      <td colspan="3" align="right"><div align="center"><a href="reg.php"></a></div></td>
      <td width="122" align="right" valign="top">
        <div align="center">
          <input name="submit" type="submit" id="submit" value="Enter the site">
Link to comment
https://forums.phpfreaks.com/topic/35617-modification-of-exsiting-login-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.