1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP error

Discussion in 'PHP' started by webber09, Jan 30, 2011.

  1. #1
    can anyone see what is wrong with this login part of my script?

    login.php
    <? 
    if (isset($_POST['submitted'])) {
    	require_once('includes/login_functions.inc.php');
    	require_once('mysqli_connect.php');
    	list ($check, $data) = check_login($dbc, $_POST['email'], $_POST['pass']);
    	if ($check) {
    		session_start();
    		$_SESSION['user_id'] = $data['user_id'];
    		$_SESSION['first_name'] = $data['first_name'];
    		$_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']);
    		$url = absolute_url ('loggedin.php');
    		header("Location: $url");
    		exit();
    	} else {
    		$errors = $data;
    	}
    	mysqli_close($dbc);
    }
    include ('includes/login_page.inc.php');
    ?>
    PHP:
    loggedin.php
    <?
    session_start();
    if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT']) ) {
    	require_once('includes/login_functions.inc.php');
    	$url = absolute_url();
    	header("Location: $url");
    	exit();
    }
    echo "<h1>Logged In!</h1>
    <p>You are now logged in, {$_SESSION['first_name']}!</p>
    <p><a href=\"logout.php\">Logout</a></p>";
    ?>
    PHP:
    as it is there is shows a Server Error!!
     
    webber09, Jan 30, 2011 IP
  2. TimK

    TimK Peon

    Messages:
    51
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What is the error that you get exactly?
     
    TimK, Jan 30, 2011 IP
  3. Tutorial Feed

    Tutorial Feed Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    On line 3 of your loggedin.php code you are missing a closing bracket. That should help.

    Also, always open your PHP tags with <?php instead of <?, not vital but some servers don't allow it.
     
    Tutorial Feed, Jan 30, 2011 IP
  4. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #4
    here is the error i recieve:

    HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

    and i cant see any missing bracket???
     
    webber09, Jan 30, 2011 IP
  5. TimK

    TimK Peon

    Messages:
    51
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Tutorial Feed spotted it but here it is with the correct parentheses.

    <?
    session_start();
    if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT']) `) ) {
        require_once('includes/login_functions.inc.php');
        $url = absolute_url();
        header("Location: $url");
        exit();
    }
    echo "<h1>Logged In!</h1>
    <p>You are now logged in, {$_SESSION['first_name']}!</p>
    <p><a href=\"logout.php\">Logout</a></p>";
    ?>
    
    PHP:
     
    TimK, Jan 30, 2011 IP
  6. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #6
    massive thanks guys :D all works :D
     
    webber09, Jan 30, 2011 IP
  7. TimK

    TimK Peon

    Messages:
    51
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Welcome, glad to help. Good eye Tutorial Feed on spotting that.
     
    TimK, Jan 30, 2011 IP
  8. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #8
    webber09, Jan 30, 2011 IP
  9. Tutorial Feed

    Tutorial Feed Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks TimK, have been there a few times myself! Still had to read that line a few times to double check my counting.
     
    Tutorial Feed, Jan 30, 2011 IP
  10. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #10
    well thanks again tutorial feed :D
     
    webber09, Jan 30, 2011 IP
  11. cp_

    cp_ Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    For future reference, you can run "php -l yourfile.php" to find syntax errors without even having to run the script. It can come in handy a lot of the time. :)
     
    cp_, Jan 30, 2011 IP