I am getting so much errors in php. I couldn't understand why. I re-checked all code but I am getting strange errors. The code below is provided to you under mit/x11 license for modification and distribution. ALL DERIVATIVES ARE WELCOME! :)
Here is the code:

<html><head><link href="style.css" rel="stylesheet" type="text/css" media="screen" /></head>
<body>
<form action="login.php" method="post">
<h1>Please enter login information</h1>
<br />
<div id=login>
<br />
<font size=1>Username: </font><input type=text id=username /> <br />
<font size=1>Password: &nbsp;</font><input type=text id=password />
<br />
<input type=submit value=Login size=6 />
</div>
<?php
$debug=true;
if ($debug==true) echo "Preprocessor is OK!";
// Connecting, selecting database
$dbconn = pg_connect("host=localhost dbname=aaaa user=postgres password=qwerty")
or die('Could not connect-- ' . pg_last_error());
echo "Sucess!";
// Performing SQL query
$querys = "SELECT pass FROM login WHERE usrname='Rishi'"// . $_POST("Username");
$result = pg_query($querys) or die('Query failed-- '); // . pg_last_error());
$password = pg_fetch_row($result);
if ($debug==true) echo "Preprocessor is OK! -- Postgresql returned Password=" . $password;
if ($debug==true) echo "Preprocessor is OK! -- HTML form returned Password=" . $_POST("username");
if ($debug==true) echo "Preprocessor is OK! -- HTML form returned Password=" . $_POST("password");
if ($debug==true) echo "Preprocessor is OK! -- Parsing if";
if ($_POST("password") == $password){
if ($debug==true) { echo 'Preprocessor is OK! -- Parsed if -- Sucess'; }s";
setcookie('TestCookie', True);
}
elseif (!$_POST("password")){
echo "<br /><font size=1 color=green>Please enter a username and password</font>";
if ($debug==true) echo "Preprocessor is OK! -- Parsed if -- elseif -- Sucess";
}
else {
echo "<br /><font size=1 color=red>Invalid username or password!</font>";
if ($debug==true) echo "Preprocessor is OK! -- Parsed if -- else -- Sucess";
}
?>
</form>
</body>
</html>

PHP Parser shows:
PHP Parse error: syntax error, unexpected T_VARIABLE in C:\Program Files\Apache
Software Foundation\Apache2.2\htdocs\login.php on line 22

Thank you in advance. :)

I am not very experienced with php, but have you tried adding a semi-colon to the end of line 21? When I did this the page seemed to load correctly.

Also, line 29 has an s and a double quote before the semi-colon, remove them.

Edited 6 Years Ago by pritaeas: n/a

This article has been dead for over six months. Start a new discussion instead.