Syntax error
Page 1 of 1
Syntax error
- Code: Select all
<html>
<head>
<title>Login</title>
</head>
<body>
<form method="post" action="login.php">
<p>Username: <input type="text" name="username"/></p>
<p>Password: <input type="text" name="password"/></p>
<p><input type="submit" value="let me in" /></p>
</form>
</body>
</html>
- Code: Select all
<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"
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>
- Code: Select all
<?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>
"Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in C:\xampp\htdocs\login.php on line 15"
It says that when I try to log in, I do not see the error could someone please point it out :D
Re: Syntax error
<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>
--
~Chris
~Chris
Re: Syntax error
thank you that fixed it guess I was staring at it to long lolnow I have a new problem which makes no sense
- Code: Select all
<?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>
Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\document.php on line 6 i don't see how its error its supposed to be there however i tried removing it anyway and it gave me this....
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\document.php on line 20 there isn't a $end do I need to add one?
Re: Syntax error
<?phpsession_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.
--
~Chris
~Chris
Re: Syntax error
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
Re: Syntax error
You kept the curly bracket in right?--
~Chris
~Chris
Re: Syntax error
yeah I forgot to put it back lol Thank you for all your help :DRe: Syntax error
Welcome--
~Chris
~Chris
Page 1 of 1