Please help: PHP login script is giving me hell :(

Discussion in 'PHP' started by content writer, Jan 15, 2010.

  1. #1
    I have a PHP login script that only allows me to log in the localhost. When I try to log in a remote server it just can't! Someone, what am I doing wrong?

    Thanks in advance...
     
    content writer, Jan 15, 2010 IP
  2. ColorWP.com

    ColorWP.com Notable Member

    Messages:
    3,120
    Likes Received:
    100
    Best Answers:
    1
    Trophy Points:
    270
    #2
    Maybe if you share the code we might be able to help.
     
    ColorWP.com, Jan 15, 2010 IP
  3. chmdznr

    chmdznr Active Member

    Messages:
    417
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #3
    probably database connection?
     
    chmdznr, Jan 15, 2010 IP
  4. content writer

    content writer Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ////log_in form



    <?
    $error = '';
    if(isset($admin_login)){

    $email = $_REQUEST['admin_email'];
    $password = $_REQUEST['admin_password'];
    $password = md5($password);

    $authAdmin = mysql_query("SELECT * FROM tbl_users WHERE email = '".$email."' AND password = '".$password."'")or die(mysql_error());
    $resultAuthAdmin = mysql_fetch_assoc ($authAdmin);
    $rows = mysql_num_rows($authAdmin);
    //exit;
    if($rows == 0){
    $error = 'Login failed, please attempt again.';
    }elseif($rows > 0){

    $_SESSION['sess_admin'] = uniqid(microtime()) . $_SERVER['REMOTE_ADDR'];

    mysql_query("UPDATE tbl_users set session_id = '".$_SESSION['sess_admin']."' WHERE user_id = '".$resultAuthAdmin['user_id']."'");

    echo "<script>window.location.href = 'admin.php';</script>";

    }





    }


    ?>



    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Travel - About</title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
    <link rel="stylesheet" type="text/css" href="style.css" />

    <link rel="stylesheet" type="text/css" href="styles/style.css" />
    <script type="text/javascript" src="thumbnailviewer2.js" defer="defer"></script>

    <script language="JavaScript" src="js-functions/user-functions.js"></script>
    <script type="text/javascript" src="thumbnailviewer2.js" defer="defer">

    /***********************************************
    * Image Thumbnail Viewer II script- ? Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/

    </script>

    </head>
    <center>
    <body style="margin-left:7px; background-color:
    #EFE7C2">
    <table border="0" style="margin-left:12px;" width="87%" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF" class="brder">
    <!--DWLayoutTable-->

    <tr>
    <td align="center"><form action="<?=$_SERVER['PHP_SELF'];?>" method="post" onSubmit="return validateAdminLogin();">
    <table width="119%" align="center" cellpadding="3" cellspacing="1" bgcolor="#ECECEC">
    <tr>
    <td>&nbsp;</td>
    <td colspan="3" class="error"><?=$error;?></td>
    </tr>
    <tr>
    <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
    <td width="34%">&nbsp;</td>
    <td width="23%">E-mail address</td>
    <td width="58%"><input name="admin_email" type="text" class="MWizard" id="admin_email" style="width:100%; height:30px;"></td>
    <td width="14%">&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>Password</td>
    <td><input name="admin_password" type="password" class="MWizard" id="admin_password" style="width:100%; height:30px;"></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td colspan="3">Forgot your password? <a href="admin_pass_reset.php">Click here.</a></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input name="admin_login" type="submit" id="admin_login" value="Login" style="width:150px; height:40px; "></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
    <td><br></td>
    <td colspan="3" class="small"><!--Forgot your password<br>
    <a href="<">Click here to reset password</a>--></td>
    </tr>
    <tr>
    <td colspan="4">&nbsp;</td>
    </tr>
    </table>
    </form></td>
    </tr>
    <tr>

    <tr align="center" valign="middle" bgcolor="#2F4666">
    <td colspan="4" bgcolor="#CB4D01"><span class="text6"></span></td>
    </tr>
    <tr align="center" valign="middle" bgcolor="#FFFFFF" class="brder">
    <td colspan="4"><span class="text5"></span></td>
    </tr>
    <tr>
    <td height="0"></td>
    <td width="73"></td>
    <td width="148"></td>
    <td width="-10"></td>
    </tr>
    </table>
    </body>
    </center>
    </html>














    ///the admin page


    <?
    session_start();
    include_once 'library/db_connect.php';

    if(isset($logoff_admin)){
    mysql_query("UPDATE tbl_users SET session_id = '' WHERE session_id = '".$sess_admin."'")or die(mysql_error());

    unset($_SESSION['sess_admin']);
    echo 'If page does not redirect in 15 seconds <a href = "admin.php">click here.</a>';

    echo "<script>window.location.href = 'admin.php';</script>";
    }


    if(isset($sess_admin)){
    if(isset($get_users_list)){
    $get_task = 'includes/users_list.php';
    }elseif(isset($get_service_list)){
    $get_task = 'includes/services_list.php';
    }
    elseif(isset($get_hottour_list)){
    $get_task = 'includes/hottour_list.php';
    }
    elseif(isset($get_industry_list)){
    $get_task = 'includes/industry_list.php';
    }elseif(isset($get_client_list)){
    $get_task = 'includes/client_list.php';
    }elseif(isset($get_product_list)){
    $get_task = 'includes/products_list.php';
    }elseif(isset($get_project_list)){
    $get_task = 'includes/project_list.php';
    }elseif(isset($get_news_list)){
    $get_task = 'includes/news_list.php';
    }
    elseif(isset($get_tour_list)){
    $get_task = 'includes/kenyan_list.php';
    }
    elseif(isset($get_tour_list)){
    $get_task = 'includes/uganda_list.php';
    }

    elseif(isset($get_tour_list)){
    $get_task = 'includes/tanzania_list.php';
    }
    elseif(isset($get_request_list)){
    $get_task = 'includes/collection_request_list.php';
    }elseif(isset($get_partner_list)){
    $get_task = 'includes/partner_list.php';
    }else{
    $get_task = 'admin_tasks.php';
    }
    }else{
    $get_task = 'admin_login.php';
    }




    ?>



    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Travel - About</title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
    <link rel="stylesheet" type="text/css" href="style.css" />

    <script type="text/javascript" src="thumbnailviewer2.js" defer="defer">

    /***********************************************
    * Image Thumbnail Viewer II script- ? Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/

    </script>


    </head>
    <center>
    <body style="margin-left:7px; background-color:
    #EFE7C2">
    <table border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF" width="97%" class="brder">
    <!--DWLayoutTable-->
    <tr align="center" style="margin-left:12px" bgcolor="#2F4666">
    <td colspan="4" valign="top" bgcolor="#CB4D01"><div id="header2"> <a href="index.html" class="logo"></a>
    <ul id="menu">
    <li><a href="index.php">Home Parge</a></li>
    <li><a href="aboutus.php">About Company</a></li>
    <li><a href="information.php">Information</a></li>
    <li><a href="hotels.php">Hotels</a></li>
    <li> <a href="services.php">services</a></li>
    <!--<li><a href="hot_tour.php">Hot Tours</a></li>-->
    <li><a href="contactus.php">Contact us</a></li>
    <li><a href="admin.php">admin</a></li>
    </ul>
    </div></td>
    </tr>
    <tr>
    <td>

    <table width="80%" align="center" cellpadding="3" cellspacing="1" bgcolor="#ECECEC">
    <tr>
    <td><? include_once $get_task; ?></td>
    </tr>
    </table>
    </td>
    </tr>
    </td>
    </tr>
    </table>
    </body>
    </center>
    </html>
     
    content writer, Jan 15, 2010 IP
  5. chmdznr

    chmdznr Active Member

    Messages:
    417
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #5
    have you edit this file (for database connection setting):
    
    library/db_connect.php
    
    Code (markup):
     
    chmdznr, Jan 15, 2010 IP
  6. content writer

    content writer Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    the thing is when i try to log in there is no error but it cannot go beyond log_in
     
    content writer, Jan 15, 2010 IP