Hey!
I got this shopcart code online, am trying to modify it but am getting an error when i try and login as an administrator.
Am new to php ......so let me know if you can help
Source code for /admin/login.php
<?php
require_once '../library/config.php'; //contains the database configuration
require_once './library/functions.php'; //contains functions such as doLogin() posted below
$errorMessage = ' ';
if (isset($_POST['txtUserName'])) {
$result = doLogin(); // default username and password is admin
if ($result != '') {
$errorMessage = $result;
}
}
?>
<html>
<head>
<title>Shop Admin - Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="include/admin.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="1" class="graybox">
<tr>
<td><img src="include/banner-top.gif" width="750" height="75"></td>
</tr>
<tr>
<td valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="20">
<tr>
<td class="contentArea"> <form method="post" name="frmLogin" id="frmLogin">
<p> </p>
<table width="350" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#336699" class="entryTable">
<tr id="entryTableHeader">
<td>:: Admin Login ::</td>
</tr>
<tr>
<td class="contentArea">
<div class="errorMessage" align="center"><?php echo $errorMessage; ?></div>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="text">
<tr align="center">
<td colspan="3"> </td>
</tr>
<tr class="text">
<td width="100" align="right">User Name</td>
<td width="10" align="center">:</td>
<td><input name="txtUserName" type="text" class="box" id="txtUserName" value="admin" size="10" maxlength="20"></td>
</tr>
<tr>
<td width="100" align="right">Password</td>
<td width="10" align="center">:</td>
<td><input name="txtPassword" type="password" class="box" id="txtPassword" value="admin" size="10"></td>
</tr>
<tr>
<td colspan="2"> </td>
<td><input name="btnLogin" type="submit" class="box" id="btnLogin" value="Login"></td>
</tr>
</table></td>
</tr>
</table>
<p> </p>
</form></td>
</tr>
</table></td>
</tr>
</table>
<p> </p>
</body>
</html>
Source code for the login function in the function.php
function doLogin()
{
// if we found an error save the error message in this variable
$errorMessage = '';
$userName = $_POST['txtUserName'];
$password = $_POST['txtPassword'];
// first, make sure the username & password are not empty
if ($userName == '') {
$errorMessage = 'You must enter your username';
} else if ($password == '') {
$errorMessage = 'You must enter the password';
} else {
// check the database and see if the username and password combo do match
$sql = "SELECT user_id
FROM tbl_user
WHERE user_name = '$userName' AND user_password = PASSWORD('$password')";
$result = dbQuery($sql);
if (dbNumRows($result) == 1) {
$row = dbFetchAssoc($result);
$_SESSION['plaincart_user_id'] = $row['user_id'];
// log the time when the user last login
$sql = "UPDATE tbl_user
SET user_last_login = NOW()
WHERE user_id = '{$row['user_id']}'";
dbQuery($sql);
// now that the user is verified we move on to the next page
// if the user had been in the admin pages before we move to
// the last page visited
if (isset($_SESSION['login_return_url'])) {
header('Location: ' . $_SESSION['login_return_url']);
exit;
} else {
header('Location: index.php');
exit;
}
} else {
$errorMessage = 'Wrong username or password';
}
}
return $errorMessage;
}
/*
Logout a user
*/
function doLogout()
{
if (isset($_SESSION['plaincart_user_id'])) {
unset($_SESSION['plaincart_user_id']);
session_unregister('plaincart_user_id');
}
header('Location: login.php');
exit;
}
phpMailer will not connect using SMTP
I am trying to use phpMailer with smtp:Code: [Select]$mailer = new PHPMailer();$mailer->IsSMTP();$mailer->Mailer = "smtp";$mailer->SMTPSecure = 'tls';
Really need helps regarding Pagination with Sort
I need someone helps regarding pagination problem...i actually want to make my page limited to let say 50 so it will look like this page1=0-50page2=51-100Then i want to sort let say based on the name
A Few Questions
Hi, I want to ask a few questions that I can't seem to find..1) I'm creating a "shortcut" system on my website, where users can add shortcuts from pages by clicking the link and it will
Checking if field is empty AND using !is_numeric
Hi lads,Need to be able to display an error message (using isset?) that says "Cant leave field blank" when someone clicks on submit after leaving the field blank. The problem is that I'm
Need help urgant
why down my code ony return one item instead of all the items selected. $arr =
Checking if a process is running (problems including psapi.dll i think...)
Ok, so all I'm trying to do is check if a program is running...
Automatically Detect Phone Model for WAP Jar Deployment
Making a wap site is fairly simple, but I'd like to know if there's a way to make it so that the wap site automatically detects the phone model and deploys the appropriate jar. Deploying the
I need an iframe that calls up a different page according to the date
hiI don't know any php (only html) and I urgently need to do the following: I need an iframe that calls up a different page according to the date e.g. on the 2th Dec a page called 'special2.php',
Do something every fifth time?
I'm trying to write a loop, but I want it to do something different after every fifth instance. Like, I want it do something like this:Quoteecho $a1;echo $a2;echo $a3;echo $a4;echo $a5.$b;echo $a6;And
why preg_match_all does not return the number of matches
My regex looks likeX[^\x{4e00}-\x{9fa5}]*Y(where X and Y are two Chinese characters)and my expression looks likepreg_match_all("/".$regex."/iu", $content, $out,