Ok here is my code for the authenticate page.

When l log in it comes on blank.

<?php

if(isset($_POST['log']))
{
$username = $_POST['username'];
$pass     = $_POST['passd'];

include("connectOrder.php");
$sql = "SELECT * FROM users WHERE user_name='$username' AND password = '$pass' AND access_level != 0";
mysql_query($sql);
$num=mysql_num_rows($sql);
if($num == 1)
{
    session_start();

$_SESSION["user_id"]=$row_sqllog["user_id"];
$_SESSION["username"]=$row_sqllog["user_name"];
   header ("Location: order.php");
 }
 [else]
 {
  header ("Location: login.php?login=wrong");
 }

 }
?>

Recommended Answers

All 2 Replies

put single quotes like this $_SESSION

your syntax for the else is wrong, it should not have been square brackets there.
your code below -

if(isset($_POST['log']))
{
	$username = $_POST['username'];
	$pass = $_POST['passd'];
	
	include("connectOrder.php");
	$sql = "SELECT * FROM users WHERE user_name='$username' AND password = '$pass' AND access_level != 0";
	mysql_query($sql);
	$num=mysql_num_rows($sql);
	if($num == 1)
	{
		session_start();
		
		$_SESSION["user_id"]=$row_sqllog["user_id"];
		$_SESSION["username"]=$row_sqllog["user_name"];
		header ("Location: order.php");
	}
	else
	{
		header ("Location: login.php?login=wrong");
	}

}

Also make sure the filepath you including is all right and also the same in header.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.