This piece of code is giving me a headache. When i run this php says it's got a parse error in line 98, which is the last one if you copy this code into a new file ( without the comment lines i added here ). I can't figure out why.
Can you help me?
/ code starts here: /
<?php
include('global.php');
mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
if ((isset($id) == false) || (isset($pw) == false)) {
header('Location: ./admin.php?action=login');
exit();
}
if ($action == 'logging') {
$query = mysql_query("SELECT id,pw FROM users WHERE name = '$name' AND pw = password('$pw')");
$results = mysql_fetch_row($query);
if (mysql_num_rows($query) == 1) {
setcookie('id',$results[0]);
setcookie('pw',$results[1]);
header('Location: ./admin.php?action=check');
exit();
}
}
if ((isset($id) == true) || (isset($pw) == true)) {
$query = mysql_query("select id from users where id = $uid and password = '$upass'");
if(@mysql_num_rows($query) == 1) {
print '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<head>
<title></title>
</head>
<body>
<p>Login sucessful!</p>
</body>
';
} else {
print '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<head>
<title></title>
</head>
<body>
<p>Login failed!</p>
</body>
';
}
if ($action == 'login') {
print '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<head>
<title></title>
</head>
<body>
<form action="./admin.php?action=logging" name="loginform" method="post">
<table align="center">
<colgroup>
<col>
<col></colgroup>
<tr>
<td>
<p>Username:</p>
</td>
<td>
<p><input type="text" name="name"></p>
</td>
</tr>
<tr>
<td>
<p>Password:</p>
</td>
<td>
<p><input type="password" name="pw"></p>
</td>
</tr>
<tr>
<td colspan="2">
<p align="center"><input type="submit"></p>
</td>
</tr>
</table>
</form>
</body>
';
}
?>
/ code ends here! /