Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

PHP help (not php-fusion)


Print Track
MODERATOR smileys disabled

hey all. ok so im learning php, and here is what im workign on:
http://www.gocode.org/PHP/index.php

try logging in.
username: admin
password: passwd

Then, try to use either the password generator, or the encrypter. it logs you out...AND take a look at the url...has all the info in there...as index.php?user=admin&pass=passwd or something like that...

im completely lost....so any help is greatly appreciated....

here is my source:

CodeDownload  

<HTML>
<HEAD><TITLE>Encrypto!</TITLE></HEAD>
<BODY BGCOLOR="BLACK" FONT="WHITE">
<CENTER>
<FONT SIZE="6" color="white">
<DIV style="width:200; border-style:double">Encrypto!</DIV>
</FONT>
<BR/>

<?PHP

$LOGIN = FALSE;

if (isset($_COOKIE['user'])) {
   $user = explode(".", $_COOKIE['user']);
   if ($user[0] == "admin" && $user[1] == "passwd") {
      setcookie("user", "admin.passwd", time()+3600);
      echo "You are logged in..... =D";
      include('enc.php');
      $LOGIN = TRUE;
   }
}

if ($_POST['user'] != "" && $_POST['pass'] != "") {
   if ($_POST['user'] == "admin" && $_POST['pass'] == "passwd") {
      echo 'You are now logged in!';
      include('enc.php');
   } else {
      echo "Login Failed!";
   }
}


if ($LOGIN == FALSE) {
   echo "
<form action='' method=POST>
   <DIV style='width:250px; color:lime; height:100px; border-style:double'>
   <input type='text' name='user' value='user'><br>
   <input type='password' name='pass' value='pass'><br>
   <input type='submit' value='Login'>
   </DIV>
</form>
";
}

?>

2 replies

It may well 'log you out' - being logged into any system actually just means tracking someones session - either through cookies or against a session server side. you could set a hidden field in your encryption form - to pass on the status of your $LOGIN variable.. or set a variable in session scope to indicate the user is logged in for the length of the stay on your site.

setting a local variable $LOGIN = TRUE doesn't actually last longer than the life of creating the page.

does your form with the encription submit in it have something like;

<input type=hidden value="<?php echo $LOGIN ?>" name="login">

which would at least mean that on submitting the form you could again pick up the status of $_POST['login'] to check again if the user is logged in. probably a long winded way of doing it - you might want to read about sessions and use that way.

Sorry if this doesn't make much sense - i'm but a hacker of php. :)
lol hacker of php...that works
author 0m3g4
forumGeneral Discussion
replies3 posts
viewed1,615 times
activeLast updated on 13 years ago
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
Users who participated in discussion: 0m3g4, krispy_b