Login | Register | FAQ
Anonymous

Syntax error

+ Post a reply

8 posts Page 1 of 1


Syntax error

by JereWoo » Tue May 01, 2012 5:56 pm

User avatar

JereWoo

  • Posts: 4
  • Joined: Tue May 01, 2012 5:50 pm

Re: Syntax error

by chrisf1288 » Tue May 01, 2012 8:35 pm

<html>
<head>
<title>Login</title>
</head>

<body>

<?php

if ($_POST["username"] == "php" && $_POST["password"] == "php")
{
session_start();
$_SESSION["Login"] = "YES";
echo "<h1> you are now logged in</h1>"; // Your forgot this semicolon and the ending h1 tag
echo "<p><a href='document.php'>Link to protected file</a><p/>";
}
else
{
session_start();
$_SESSION["login"] = "no";
echo "<h1> incorrect login </h1>";
echo "<p><a href='document.php'>Link to protected file</a><p/>";
}
?>
</body>
</html>
User avatar

chrisf1288

  • Posts: 128
  • Joined: Sun Jun 26, 2011 1:01 am
--

Re: Syntax error

by JereWoo » Wed May 02, 2012 4:06 pm

User avatar

JereWoo

  • Posts: 4
  • Joined: Tue May 01, 2012 5:50 pm

Re: Syntax error

by chrisf1288 » Wed May 02, 2012 4:40 pm

<?php
session_start();

if ($_SESSION["Login"] !="YES")
{
header("Location: form.php");
}

?>

<html>
<head>
<title>protected files</title>
</head>

<body>
<h1>This document is protected</h1>
<p>login if you want to see ;)</p>
</body>
</html>



Well the problem is you forgot the semicolon again. But don't worry, that happens to everyone from time to time.
User avatar

chrisf1288

  • Posts: 128
  • Joined: Sun Jun 26, 2011 1:01 am
--

Re: Syntax error

by JereWoo » Wed May 02, 2012 5:09 pm

damn semicolons -_-
I'm getting this error now:Parse error: syntax error, unexpected $end in C:\xampp\htdocs\document.php on line 20
I haven't had any problems up to this lesson lol
User avatar

JereWoo

  • Posts: 4
  • Joined: Tue May 01, 2012 5:50 pm

Re: Syntax error

by chrisf1288 » Wed May 02, 2012 5:13 pm

You kept the curly bracket in right?
User avatar

chrisf1288

  • Posts: 128
  • Joined: Sun Jun 26, 2011 1:01 am
--

Re: Syntax error

by JereWoo » Wed May 02, 2012 5:20 pm

yeah I forgot to put it back lol Thank you for all your help :D
User avatar

JereWoo

  • Posts: 4
  • Joined: Tue May 01, 2012 5:50 pm

Re: Syntax error

by chrisf1288 » Wed May 02, 2012 5:37 pm

Welcome
User avatar

chrisf1288

  • Posts: 128
  • Joined: Sun Jun 26, 2011 1:01 am
--


+ Post a reply

Page 1 of 1