Jump to content

Recommended Posts

I am trying to make a login without mysql and it looks like

<?php 
session_start();
$username = "Admin";
$password = "user";
if($_POST['login'] == "yes"){
$user = $_POST['username'];
$pass = $_POST['password'];
if($user == $username && $pass == $password){
	$_SESSSION['admin'] = "yes";
	header("location: admin.php");
	echo "<pre> Login Valid</pre>";
}	
else{
	echo "<pre>Invalid Login Information</pre><br/>";
	die(include("login.html"));
}
}
if($_SESSION["admin"] != "yes"){
echo "Session: ".$_SESSION["admin"]."<br/>";
die(include("login.html"));
}
else{
echo "logged in";
}
?>

It test the username perfectly except it doesn't display the session right after logging in as it should it just says Session: and the login part

I have tried Double/single quotes on the session no difference, kinda getting annoying

heres where you initialize your session right?

if($user == $username && $pass == $password){

$_SESSSION['admin'] = "yes";

header("location: admin.php");

echo "<pre> Login Valid</pre>";

}

 

now i believe that condition is not satisfied so no initialization took place why?

 

if that is correct the you should get the error saying header cannot send somtething because you echo something under the header

weird i think it actually worrk but because the header thing it doesnt show the message

try to remove the header file or comment it first

in this code

if($user == $username && $pass == $password){

      $_SESSSION['admin'] = "yes";

      header("location: admin.php");-<<<<<<<<<<comment this first

      echo "

yeah, teng84 no good

<?php 
session_start();
$username = "Admin";
$password = "user";
if($_POST['login'] == "yes"){
$user = $_POST['username'];
$pass = $_POST['password'];
if($user == $username && $pass == $password){
	$_SESSSION['admin'] = "yes";
	//header("location: admin.php");
	echo "<pre>match</pre>";
}	
else{
	echo "<pre>Invalid Login Information</pre><br/>";
	die(include("login.html"));
}
}
if($_SESSION['admin'] != "yes"){
echo "Session: ".$_SESSION['admin']."<br/>";
die(include("login.html"));
}
else{
echo "logged in";
}
?>

technically its not an error (unless you are using strict) because you could have a superglobal array called SESSSION (three Ss) which all ti was doing was registering a static value instead of the session value.  I would need an editior that would pick up on predefined superglobals, which notepad++ doesnot

dreamweaver is not a text editor which is what you really need to build code in.  Dreamweaver is for the novice person who can't build layouts by hand so they use the GUI's in dreamweaver to build code.  You can find text editors with ftps built into them for your needs if that is what you use it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.