Jump to content

PHP - Login


Twist3d

Recommended Posts

Hello again.

Well, this is a little strange for me. I don't know if its my host or what.

But I posted a topic on this same matter, and got it fixed quickly.

Now since then I can't remember if I edited anything on the page, but its doing the same problem AGAIN.

So I thought that if i edited something, I could goto the topic I made which had the correct code.

 

http://www.phpfreaks.com/forums/index.php/topic,290920

 

So it is EXACTLY the way it is in the above ^ which worked great.

But now, it doesn't. I'm confused, but you can get all of the code from that link, but the login2 (The one that creates the session) here:

 

case 'login2':
session_start();
$password = $_POST['password'];
$sql = "SELECT * FROM passwords WHERE Admin='$password'";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
if($count==1){
$_session['Admin'] = 'Admin';
echo "<center>Logged in as Administrator</center>";
?>
<meta http-equiv="REFRESH" content="0;url=index.php"></HEAD>
<?php
}else{
$sql2="SELECT * FROM passwords WHERE Moderator='$password'";
$result2 = mysql_query($sql2);
$count2 = mysql_num_rows($result2);
if($count2==1){
$_session['Mod'] = 'Mod';
echo "<center>Logged in as Moderator</center>"; 
?>
<meta http-equiv="REFRESH" content="0;url=index.php"></HEAD>
<?php
}else{
echo "<center>Wrong password!</center>";
}
}
break;

 

Cheers.

 

P.S

IF YOUR WONDERING WHAT THE PROBLEM IS:

Sorry I didn't post on this, but I'm trying to create a session so that I can get this:

 

<?php
session_start();
if (isset($_SESSION['Mod'])){
?>
<li><a href="index.php?action=logout">Logout (Mod)</a></li>
<li><a href="control.php">Mod Panel</a></li>
<?php
}else{
if (isset($_SESSION['Admin'])){
?>
<li><a href="index.php?action=logout">Logout (Admin)</a></li>
<li><a href="control.php">Admin Panel</a></li>
<?php
}else{
?>
<li><a href="index.php?action=login">Login ()</a></li>
<?php
}
}
?>

 

Working, But when I login, it refreshes me home but it still says "Login ()" and not "Logout (Mod/Admin)".

 

Link to comment
https://forums.phpfreaks.com/topic/195404-php-login/
Share on other sites

What you've posted here is using $_session, not $_SESSION.  That was the problem in the original topic you linked to.  Only $_SESSION in uppercase will work.

 

The link I provided shows that I changed it to that and thanked the guy who showed me that was the problem.

In other words, I have already done it. Sorry for not updating the code.

Link to comment
https://forums.phpfreaks.com/topic/195404-php-login/#findComment-1026845
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.