Hey everyone,
i have a little problem with my login system, i want to make it work from 2 pages other than one
index.html (user & pass form)
login.php (the script)
so that i can make several login pages and direct them all to one script (OR)
how can i make a script connect to a page with a form already on it in php...
http://project.icthost.com/
the members login box should submit to page "admin/index.php"
and i need 2 know how 2 make it actually login on that page instead of just showing me a form.
this is the code i have got at the moment (i need someone to split this for me and post it in here)
<?php
$login_page = true;
require 'config.php';
require 'cdb.php';
require 'adminconfig.php';
$db = new cDB();
if( !$db->connect(
$config['db_name'],
$config['db_host_port'],
$config['db_user'],
$config['db_pswd'] )) {
die ("Cannot connect to the DB!");
}
// Check if user not logged in and request to login
if( (!isset($session['authenticated']) || !$session['authenticated']) &&
($_GET['action'] == 'login') ) {
// User not authorized, login requested
$login = addslashes(trim($_GET['login']));
$pswd = md5($_GET['pswd']);
if( $db->query("select id from php_admins where userid='$login' and pass='$pswd'") ) {
if( $db->rows() > 0 ) {
$res = $db->fetch_array();
$session['authenticated'] = true;
$session['active_user'] = $login;
$session['active_user_id'] = (int)$res['id'];
}
}
}
if( isset($session['authenticated']) && $session['authenticated'] ) {
// User authorized - show the rest of the admin.php page
?>
<html>
<head><title>Members Login</title>
</head>
<body><center><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="25%" id="AutoNumber1" bgcolor="#FFFFCC" bordercolor="#000000">
<tr>
<td width="100%">
<p align="center"><b><font face="Tahoma" size="2">Website Administrator Login</font></b></p>
<p align="center"><font face="Tahoma" size="2">Thank You,<br>
Please Click The Continue Link Below To Proceed To The Administration Section.<br>
<br>
</font>
<a href="admin.php"><font face="Tahoma" size="3"><i><b>(Continue)</b></i></font></a></p>
<p align="center"><font face="Tahoma" size="2">
<?php
echo "You are currently Logged in as <b>".$session['active_user']."</b><br>\n</font></b>";
echo "<p align='center'>
<font face='Tahoma' size='2'>User Authorized !<br>
</font></p>
</table>
";
} else {
//User not authorized - show login form
?>
<html>
<head><title>Administrator Login</title>
</head>
<body><center><table border="2" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="25%" id="AutoNumber1" bgcolor="#FFFFCC" bordercolor="#000000">
<tr>
<td width="100%">
<p align="center"><b><font face="Tahoma" size="2">Website Administrator Login</font></b></p>
<form method="GET">
<input type=hidden name="action" value="login">
<p align="center">
<font face="Tahoma">
<font size="2">Username: </font>
<font face="Verdana" size="1">
<input type=text name="login" size="20" style="background-color: #FFFFCC; font-family: Verdana; font-size: 12px; color: #000000; font-weight: bold; border: 1px solid #000000; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1"></font></font></p>
<p align="center"><font face="Tahoma"><font size="2">Password: </font>
<font face="Verdana" size="1">
<input type=password name="pswd" size="20" style="background-color: #FFFFCC; font-family: Verdana; font-size: 12px; color: #000000; font-weight: bold; border: 1px solid #000000; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1"></font></font></p>
<p align="center">
<font face="Tahoma">
<input type="submit" value="Login" name="B1" style="background-color: #FFFFCC; border-style: solid; border-width: 5; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1"></font></p>
</form>
</td>
</tr>
</table></center>
</body>
</html>
<?php
}
?>
As usual anyone who helps me gets hosting/reseller for free for 1 year.
Thank You,
Gavin Hanson
ICThost Communications LTD