Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    Any good soul want to clean this code ??? I Get a lot of errors

    (Username1 and Password1 are posted by a separate form and function_connect.php includes database connection. I saw it on a tutorial but couldn't make it work ....

    PHP Code:
    <?php

    $username1 
    $_POST['user'];
    $password1 $_POST['pass'];
    include 
    "function_connect.php";

    // valid login credentials 
    if ($username1 && $password1) { 
    $sql="SELECT id, username, password FROM pointgather WHERE 
    username='
    $username1' AND password='$password1'";
    $result mysql_query ($sql) or die('Error: ' mysql_error());
    $user_data mysql_fetch_array ($result);
    $id $user_data ['id'];
    $username $user_data ['username'];
    $password $user_data ['password'];

     if (
    $user_data['id'] > 0) { 
      
    setcookie ("user"md5($user_data['username']));  
      
    setcookie ("pass"md5($user_data['password']));  
      print 
    "success"
     } else { 
    $login_errortrue; } 


    // grab current time 
    $time=time(); 

    // handle the logout event 
    if ($logout == true) {     
     
    setcookie ("user"md5($username1), $time-3200);  
     
    setcookie ("pass"md5($password1), $time-3200);  
    // header("Location: index.php"); 


    // handle validation event 
    if ($_POST[user] && $_POST[pass]) {     
     if (
    $username1==$username && $password1==$password) { 
      
    setcookie ("user"md5($username1), $time+3200);  
      
    setcookie ("pass"md5($password1), $time+3200);  
     
    // header("Location: index.php"); 
     
    } else { $login_errortrue; } 


    // handle login event, both successful and erroneous, or show login screen 
    if ($login_error == true) { ?> 
     <table align=center style="font-family:arial; 
    font-size:12; border:1 solid #000000;"> 
      <tr><td align=center bgcolor=#123dd4>LOGIN ERROR</td></tr> 
      <tr><td align=center><b>Invalid Username and/or Password</b><br><br>
    <a href=index.php>Back</a></td></tr> 
    </table> 
    <? 
    } elseif ($_COOKIE[user] == md5($username) && $_COOKIE[pass] == 
    md5($password)) { ?> 
     <table align=center style="font-family:arial;
     font-size:12; border:1 solid #000000;"> 
      <tr><td align=center bgcolor=#123dd4>SECURE AREA</td></tr> 
      <tr><td align=right>
    <a href=index.php?logout=true>Logout</a></td></tr> 
      <tr><td>You have successfully logged in.<br><br> 
       Encrypted Username: <b><?=  $_COOKIE['user'?></b><br> 
       Encrypted Password: <b><?= $_COOKIE['pass'?></b><br> 
      </td></tr> 
    </table> 
    <? 
    }
    ?>
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  2.  

  3. #2
    Member Seraph's Avatar
    Join Date
    Sep 2003
    Posts
    81
    Member #
    3090
    what are the errors?


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:47 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com