Jump to content

gomesgomes

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gomesgomes's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I got that part to work on my own but the following code I need to convert it into a string. <div> HERE IS YOUR USER DATA:<br /> <label class="data">username:<?php echo $_SESSION['username'] ?><br> password: <?php echo $_SESSION['password'] ?><br></label> HERE IS YOUR SESSION DATA:<br /> <label class="data"> <?php echo (session_name().": ".session_id()) ?><br> <?php echo ("SESSION DATA: ".session_encode() )?> </label> </div> <div><a href="logoff.php">Logoff</a></div>
  2. Nope sorry, I think it will be impossible to have all 5 (or even 4) in one file. file1 and 2 can go together, but that is about it. But I may be wrong, maybe someone more advanced may be able to do it. But I cannot help. Sorry thank you for trying.
  3. I am trying to do it with a series of if statements. therefore, it should work based on the conditions of each if statement but I cannot put together. CAN YOU GET THE FIRST 4 TO WORK BY PUTTING THEM ALL TOGETHER? I WILL TRY TO FIGURE OUT HOW THE LOGOUT PART WORKS.
  4. I added that and it still doesn't work and I get this error parse error: syntax error, unexpected '<' in C:\Users\Gomes\Desktop\XAMPP\htdocs\index.php on line 74 I need them to be converted into a single file. I cannot upload the files so I am going to paste the originals here file 1 : index.php <html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <!--USERID: webdeveloper PASSWORD: master --> <title>LOGIN WEB SESSION</title> <link rel="stylesheet" type="text/css" href="loginsession.css" /> </head> <body> <form action="logon.php" method="post"> <table> <tr><td width="100">Username:</td><td width="200"><input type="text" name="username"></td></tr> <tr><td width="100">Password:</td><td width="200"><input type="password" name="password"></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Login"></td></tr> </table> </form> </body> </html> file 2 : logon.php <?php function clean($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $user = clean($_POST['username']); $pass = clean($_POST['password']); if ($user == "webdeveloper" && $pass == "master") { session_start(); $_SESSION['username'] = $user; $_SESSION['password'] = $pass; $_SESSION['ON']="TRUE"; $lifetime=600; setcookie(session_name(),session_id(),time()+$lifetime); header( 'Location: inside.php' ) ; exit(); } else { header( 'Location: index.php' ); session_destroy(); exit(); } ?> file 3 : checker.php <?php session_start(); if ($_SESSION['ON'] =="FALSE" || $_SESSION['ON']==null) { header( 'Location: index.php?error=invalid-login' ); session_unset(); session_destroy(); exit(); } ?> file4: inside.php <?php include "checker.php" ?> <html><head><title>LOGIN WEB SESSION</title> <link rel="stylesheet" type="text/css" href="loginsession.css" /> </head> <body><div>LOGIN WELCOME</div> <div> HERE IS YOUR USER DATA:<br /> <label class="data">username:<?php echo $_SESSION['username'] ?><br> password: <?php echo $_SESSION['password'] ?><br></label> HERE IS YOUR SESSION DATA:<br /> <label class="data"> <?php echo (session_name().": ".session_id()) ?><br> <?php echo ("SESSION DATA: ".session_encode() )?> </label> </div> <div><a href="logoff.php">Logoff</a></div> </body> </html> file5: logooff.php <?php header( 'Location: index.php' ); session_start(); session_unset(); session_destroy(); exit(); ?>
  5. In if ($step == 2) { } i suppose to convert that part to a string but when i try I am getting errors.
  6. I am trying to convert 6 files into a single 1 php file. I have attached the original files. I need help because I don't know where I am going wrong. this what I have done so far : <?php session_start(); if ($_SESSION['ON'] =="FALSE" || $_SESSION['ON']==null) { header( 'Location: index.php?error=invalid-login' ); session_unset(); session_destroy(); exit(); } ?> <html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>LOGIN WEB SESSION</title> <link rel="stylesheet" type="text/css" href="loginsession.css" /> </head> <body> <?php // If the step is one, show the correct form // if ($step == 0) { echo '<form action="index.php?step=2" method="post"> <table> <tr><td width="100">Username:</td><td width="200"><input type="text" name="username"></td></tr> <tr><td width="100">Password:</td><td width="200"><input type="password" name="password"></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Login"></td></tr> </table> </form>'; } else if ($step == 1) { // Create the step 2 section of the page // function clean($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $user = clean($_POST['username']); $pass = clean($_POST['password']); if ($user == "webdeveloper" && $pass == "master") { session_start(); $_SESSION['username'] = $user; $_SESSION['password'] = $pass; $_SESSION['ON']="TRUE"; $lifetime=600; setcookie(session_name(),session_id(),time()+$lifetime); header( 'Location: index.php?step=2' ) ; exit(); } else { header( 'Location: index.php' ); session_destroy(); exit(); } } else if ($step == 2) <div>LOGIN WELCOME</div> <div> HERE IS YOUR USER DATA:<br /> <label class="data">username:'; <?php echo $_SESSION['username'] ?> <br> password: <?php echo $_SESSION['password'] ?> <br></label> HERE IS YOUR SESSION DATA:<br /> <label class="data"> <?php echo (session_name().": ".session_id()) ?><br> <?php echo ("SESSION DATA: ".session_encode() )?> </label> </div>index.php?step=3">Logoff</a></div> } else if ($step == 3) { // Create the step 4 section of the page // header( 'Location: index.php' ); session_start(); session_unset(); session_destroy(); exit(); } ?> </body> </html>
×
×
  • 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.