PHP Client Login with lost password.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
srednatonmi
Forum Newbie
Posts: 15
Joined: Wed Mar 19, 2008 10:01 pm

PHP Client Login with lost password.

Post by srednatonmi »

I have changed a little info in the following code but it is structurally the same. I've been given the task of getting into the client login to add books to a web bookstore and we don't have the password. What I do have is the source of all the files from the site_admin area including clientlogin.php. I will not be getting a password, and a password is not super important at this point, but I do need to be able to access the index.php page so I can perform the desired functions.

Client_login.php

Code: Select all

<?php
$page = "login";
GLOBAL $username;
GLOBAL $password;
GLOBAL $submit_login;
$username_error = false;
$password_error = false;
$error_message = "";
 
if ($submit_login != "" && $username != "" && $password != "")
{
    session_start();
    session_register("username");
    session_register("password");
    header("Location: login_util.php?".sid);
    exit;
}
else
{
    if (empty($e))
    {
        if ($submit_login)
        {
            if (!$username)
            {
                $username_error = true;
            }
            if (!$password)
            {
                $password_error = true;
            }
        }
    }
    else if ($e == "1")
    {
        $error_message = "Error: Could not connect to database.";
    }
    else if ($e == "2")
    {
        $error_message = "Login Failed.<br />Invalid User Name and/or Password.";
    }
?>
<?php include("includes/copyright.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title></title>
    
    <link rel="stylesheet" href="stylesheet/penfield.css" type="text/css">
    <script src="javascript/javascripts.js"></script>
</head>
 
<body marginheight="0" marginwidth="0">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#330099">
    <tr>
        <td align="center" valign="middle" width="100%">
            <img src="../images/empty.gif" width="1" height="25" alt="" border="0"><br />
            <table width="300" border="0" cellspacing="0" cellpadding="1" align="center" bgcolor="#000000">
                <tr>
                    <td>
                        <table width="300" border="0" cellspacing="0" cellpadding="5" align="center" bgcolor="#ffffff">
                            <tr>
                                <td bgcolor="#ffffff" align="center"><img src="../images/logo_120.gif" width="120" height="76" alt="" border="0"></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table width="300" border="0" cellspacing="0" cellpadding="1" align="center" bgcolor="#000000">
                            <tr>
                                <td align="center" class="medTitle" bgcolor="#cccc99"><img src="../images/empty.gif" width="1" height="5" alt="" border="0"><br />Penfield Press Login<br /><img src="../images/empty.gif" width="1" height="5" alt="" border="0"></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table width="300" border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#9999cc">
                            <tr>
                                <td class="mainText" align="center" colspan="2">
<?php
    if ($error_message != "")
    {
        print ("<br /><font color=\"#99ffff\"><b>".$error_message."</b></font>");
    }
    if ($username_error || $password_error)
    {
?>
<br /><font color="#99ffff"><b>There were missing fields</b></font>
<?
    }
    else
    {
?>
&nbsp;      
<?
    }
?>
                                </td>
                            </tr>
                            <tr><form method="post" action="client_login.php">
                                <td class="mainText" align="right">
<?
    if ($username_error)
    {
?>
<font color="#99ffff"><b>User Name</b></font><br />
<?
    }
    else
    {
?>
User Name<br />
<?
    }
?>
                                </td>
                                <td>
                                <input type="text" name="username" size="17" maxlength="25" value="<?php print($username);?>">
                                </td>
                            </tr>
                            <tr>
                                <td class="mainText" align="right">
<?php
    if ($password_error)
    {
?>
<font color="#99ffff"><b>Password</b></font><br />
<?
    }
    else
    {
?>
Password<br />
<?
    }
?>
                                </td>
                                <td>
                                <input type="password" name="password" size="17" maxlength="25" value="<?php print($password);?>">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">&nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                <input type="submit" value="&raquo;&nbsp; login &nbsp;&laquo;" name="submit_login">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">&nbsp;
                                </td>
                            </tr></form>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td class="copyText" align="center" colspan="2"></td>
    </tr>
</table>
 
</body>
</html>
<?php
}
?>
 
Index.php (the site I need to be able to use):

Code: Select all

<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title></title>
<script scr="javascript/javascripts.js"></script>
<link rel="stylesheet" href="stylesheet/penfield.css" type="text/css">
</head>
<body topmargin="0" marginheight="0">
<img src="../images/empty.gif" width="1" height="30" alt="" border="0"><br />
<table width="500" border="0" cellspacing="0" cellpadding="1" align="center" bgcolor="#000000">
    <tr>
        <td>
            <table width="100%" border="0" cellspacing="0" cellpadding="5" align="center" bgcolor="#ffffff">
                <tr>
                    <td bgcolor="#ffffff" align="left" width="75"><img src="../images/logo_75.gif" width="75" height="48" alt="" border="0"></td>
                    <td align="center" class="blueText" bgcolor="#ffffff" width="100%"><img src="../images/empty.gif" width="1" height="10" alt="" border="0"><br /><b><?php print($customer_name);?><br />Site Administration</b><br /><img src="../images/empty.gif" width="1" height="5" alt="" border="0"></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr>
                    <td align="center" class="medTitle" bgcolor="#cccc99"><img src="../images/empty.gif" width="1" height="5" alt="" border="0"><br />What would you like to do?<br /><img src="../images/empty.gif" width="1" height="5" alt="" border="0"></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <table width="100%" border="0" cellspacing="0" cellpadding="10" align="center" bgcolor="#9999cc">
                <tr>
                    <td class="mainText"><img src="../images/empty.gif" width="1" height="10" alt="" border="0"><br />
                    <b>Images</b><br />
                    &nbsp;&nbsp;&nbsp;<a href="images.php?action=list" class="adminLink">View All Images</a><br />
                    &nbsp;&nbsp;&nbsp;<a href="images.php?action=add" class="adminLink">Add New Images</a><br />
                    </td>
                </tr>
                <tr>
                    <td class="mainText"><img src="../images/empty.gif" width="1" height="10" alt="" border="0"><br />
                    <b>Book Listings</b><br />
                    &nbsp;&nbsp;&nbsp;<a href="book_listings.php?action=list" class="adminLink">View All Book Listings</a><br />
                    &nbsp;&nbsp;&nbsp;<a href="book_listings.php?action=add" class="adminLink">Add New Book Listings</a><br />
                    &nbsp;&nbsp;&nbsp;<a href="book_listings.php?action=search" class="adminLink">Search/Edit Book Listings</a><br />
                    </td>
                </tr>
                <tr>
                    <td class="mainText"><img src="../images/empty.gif" width="1" height="10" alt="" border="0"><br />
                    <b>Book Categories & Scheduling</b><br />
                    &nbsp;&nbsp;&nbsp;<a href="book_categories.php?action=list" class="adminLink">View All Book Categories</a><br />
                    &nbsp;&nbsp;&nbsp;<a href="book_categories.php?action=add" class="adminLink">Add New Book Category</a><br />
                    </td>
                </tr>
                <tr>
                    <td class="mainText"><img src="../images/empty.gif" width="1" height="10" alt="" border="0"><br />
                    <b>Articles/Components</b><br />
                    &nbsp;&nbsp;&nbsp;<a href="articles.php?action=list" class="adminLink">View All Articles</a><br />
                    &nbsp;&nbsp;&nbsp;<a href="articles.php?action=add" class="adminLink">Add New Article</a><br />
                    </td>
                </tr>
                <tr>
                    <td><img src="../images/empty.gif" width="1" height="15" alt="" border="0"></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <table width="100%" border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#9999cc">
                <tr>
                    <td class="smallText"><img src="../images/empty.gif" width="1" height="5" alt="" border="0"></td>
                </tr>
                <tr>
                    <td class="smallText"><img src="../images/empty.gif" width="1" height="5" alt="" border="0"></td>
                </tr>
            </table>
        </td>
    </tr>
</table>
 
</body>
</html>
 
Thank you in advance,
Anders
Post Reply