Results 1 to 6 of 6

Thread: What's wrong?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    236

    Question What's wrong?

    PHP Code:
    <?php
    include('config.php);
    if(isset($_COOKIE['
    BSComputersU']) && isset($_COOKIE['BSComputersP'])){
        $username=$_COOKIE['
    BSComputersU'];
        $query = mysql_query("SELECT username,password FROM users WHERE username = '
    $username'") or die(mysql_error());
        $data = mysql_fetch_array($query);
        $password=$_COOKIE['
    BSComputersP'];
        if($data['
    password'] != ($password)) {
            header("Location: index.php");
            }
        else{
        if(!isset($_COOKIE['
    BSComputersU']) && !isset($_COOKIE['BSComputersP'])){
        header("Location: index.php");
            }
        else{
        $query = mysql_query("SELECT username,password FROM users WHERE username = '
    $username'") or die(mysql_error());
        $row = mysql_fetch_array($query);
        $_SESSION["s_username"] = $row['
    username'];
        header("Location: index.php"); 
        }
    }
    ?>
    I get a parse error on line 3

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: What's wrong?

    include('config.php');

    The syntax highlighting should show you that

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    236

    Re: What's wrong?

    DOOH! Thnx....but now there's a parse error on line 22...

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: What's wrong?

    You're missing a closing brace.

    Use consistent indenting, then you will not miss these things

    I went through all the code for you.
    PHP Code:
    <?php
      
    include('config.php');
      
      if (isset(
    $_COOKIE['BSComputersU']) && isset($_COOKIE['BSComputersP'])) {
        
    $username $_COOKIE['BSComputersU'];
        
    $query mysql_query(
          
    'SELECT username,password '.
          
    'FROM users WHERE username = \''.$username.'\''
        
    );
        if (
    mysql_errno())
          echo 
    mysql_error();
        
        
    $data mysql_fetch_array($query);
        
    $password $_COOKIE['BSComputersP'];
        
        if (
    $data['password'] != $password) {
          
    header('Location: index.php');
        }
        else if(!isset(
    $_COOKIE['BSComputersU']) && !isset($_COOKIE['BSComputersP'])){
          
    header('Location: index.php');
        }
        else {
          
    $query mysql_query(
            
    'SELECT username,password '.
            
    'FROM users WHERE username = \''.$username.'\''
          
    );
          if (
    mysql_errno())
            echo 
    mysql_error();
          
          
    $row mysql_fetch_array($query);
          
    $_SESSION['s_username'] = $row['username'];
          
    header('Location: index.php');
        }
      }
    ?>
    Last edited by penagate; Mar 20th, 2006 at 05:42 AM.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    236

    Re: What's wrong?

    Wow, thanx dude!

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    236

    Re: What's wrong?

    Hmm, it won't recognize me when the browser is restarted:
    Check.php:
    PHP Code:
    <?php
    if(isset($_COOKIE['BSComputersU']) && isset($_COOKIE['BSComputersP'])){
    header("Location: iscookie.php");
    }
    include(
    'config.php');
    // connect to the mysql database server.
    mysql_connect ($dbhost$dbusername$dbuserpass);
    mysql_select_db($dbname) or die('Cannot select database');
    if (
    $_POST['username']) {
    //did they supply a password and username
    $username=$_POST['username'];
    $password=$_POST['password'];
    if (
    $password==NULL) {
    echo 
    "<center>Du har ikke indtastet et kodeord!</center><br>
    <center>
    <h1>Login</h1>
    <form action='check.php' method='POST'>
    <table style='border:1px solid #000000;'>
    <tr>
    <td align='right'>
    Brugernavn: <input type='text' size='15' maxlength='25' name='username'>
    </td>
    </tr>
    <tr>
    <td align='right'>
    Kodeord: <input type='password' size='15' maxlength='25' name='password'>
    </td>
    </tr>
    <tr>
    <td align='center'>
    <input type='submit' value='Login'>
    </td>
    </tr>
    <tr>
    <td align='center'>
    <a href='register.php'>Opret bruger her</a>
    </td>
    </tr>
    </table>
    </form></center>
    "
    ;
    }else{
    $query mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
    $data mysql_fetch_array($query);
    if(
    $data['password'] != md5($password)) {
    echo 
    "<center>Du har indtastet forkert brugernavn eller kodeord! Prøv igen<br><center>
    <h1>Login</h1>
    <form action='check.php' method='POST'>
    <table style='border:1px solid #000000;'>
    <tr>
    <td align='right'>
    Brugernavn: <input type='text' size='15' maxlength='25' name='username'>
    </td>
    </tr>
    <tr>
    <td align='right'>
    Kodeord: <input type='password' size='15' maxlength='25' name='password'>
    </td>
    </tr>
    <tr>
    <td align='center'>
    <input type='submit' value='Login'>
    </td>
    </tr>
    <tr>
    <td align='center'>
    <a href='register.php'>Opret bruger her</a>
    </td>
    </tr>
    </table>
    </form></center>
    </center>"
    ;
    }else{
    if (isset(
    $_POST['husklogin']) && (bool)$_POST['husklogin']) {
      
    setcookie('BSComputersU'$usernametime() + 3600 24 365);
      
    setcookie('BSComputersP'md5($password), time() + 3600 24 365);
    }
    $query mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
    $row mysql_fetch_array($query);
    $_SESSION["s_username"] = $row['username'];
    header("Location: index.php"); 
    }
    }
    }
    ?>
    <script language="javascript" type="text/javascript">
    function createRequestObject()
    {
        var request_o; //declare the variable to hold the object.
        var browser = navigator.appName; //find the browser name
        if(browser == "Microsoft Internet Explorer"){
            /* Create the object using MSIE's method */
            request_o = new ActiveXObject("Microsoft.XMLHTTP");
        }else{
            /* Create the object using other browser's method */
            request_o = new XMLHttpRequest();
        }
        return request_o; //return the object
    }


    var http = createRequestObject();
    function destorySession()
    {
        try
        { 
        http.open('get', 'destroy.php');
        http.send(null);
        }
        catch(Exception)
        {
            http = createRequestObject();
            destorySession();
        }
    }

    window.onunload = destorySession();
    </script>
    iscookie.php:
    PHP Code:
    <?php
      
    include('config.php');
      
    mysql_connect ($dbhost$dbusername$dbuserpass);
      
    mysql_select_db($dbname) or die('Cannot select database');
      if (isset(
    $_COOKIE['BSComputersU']) && isset($_COOKIE['BSComputersP'])) {
        
    $username $_COOKIE['BSComputersU'];
        
    $query mysql_query(
          
    'SELECT username,password '.
          
    'FROM users WHERE username = \''.$username.'\''
        
    );
        if (
    mysql_errno())
          echo 
    mysql_error();
        
        
    $data mysql_fetch_array($query);
        
    $password $_COOKIE['BSComputersP'];
        
        if (
    $data['password'] != $password) {
          
    header('Location: index.php');
        }
        else if(!isset(
    $_COOKIE['BSComputersU']) && !isset($_COOKIE['BSComputersP'])){
          
    header('Location: index.php');
        }
        else {
          
    $query mysql_query(
            
    'SELECT username,password '.
            
    'FROM users WHERE username = \''.$username.'\''
          
    );
          if (
    mysql_errno())
            echo 
    mysql_error();
          
          
    $row mysql_fetch_array($query);
          
    $_SESSION['s_username'] = $row['username'];
          
    header('Location: index.php');
        }
      }
    ?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width