PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
session_start();
?>
<head>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<?php
$db_connect = @mysql_connect('localhost', 'user', 'pass');
// the "@" is used to supress the generic function error.
if (!$db_connect) { // if value in variable is false (!)
die('Could not connect to MySQL database server, the server returned the error: '.mysql_error());
}
$db = @mysql_select_db('dbname');
if (!$db) { // if value in variable is false (!)
die('Could not select MySQL database, the server returned the error: '.mysql_error());
}
?>
<table width="100%">
<tr>
<td class="title"><b>Login to your admin account at 8th Dimension</b></td>
</tr>
<tr>
<?
if (!isset($HTTP_GET_VARS['do'])) {$do = "false";}
else {$do = $HTTP_GET_VARS['do'];}
if ($do == "false") {
?>
<td class="content">
<table>
<form action="index.php?act=login&do=true" method="post">
<tr><td>Username:</td><td><input type="text" name="uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="password"></td></tr>
<tr><td></td><td><input type="submit" value=" Submit "></td></tr>
</form>
</table>
</td>
<?
}
else {
$uname = $HTTP_POST_VARS['uname'];
$pass = $HTTP_POST_VARS['password'];
if ($uname == "" or $pass == "") {
echo "Sorry, You haven't fully completed your information. All fields are required. Please go <a href="#" onClick="history.back(-1);">back</a> and re-enter your information.";}
else {
$sql = "select a_uname, a_pass from admins where a_uname = $uname and a_pass = $pass";
$sql = mysql_query($sql) or die(mysql_error());
$sql = mysql_num_rows($sql);
if ($sql >= 1) {
session_register("admin_8thd");
$_SESSION["admin_uname"] = $HTTP_POST_VARS["uname"];
echo "<font color="red">You have successfully logged in as $uname!</font>";}
else {
?>
<table>
<font color="red">Your username and/or password was incorrect. Please try again. Your IP has been taken and the webmaster has been notified for security reasons.</font>
<form action="index.php?act=login&do=true" method="post">
<tr><td>Username:</td><td><input type="text" name="uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="password"></td></tr>
<tr><td></td><td><input type="submit" value=" send "></td></tr>
</form>
</table>
<? }} ?>
</center>
It says: Parse error: parse error, expecting `','' or `';'' in /home/eighth-d/public_html/admin/index.php on line 54
<?
session_start();
?>
<head>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<?php
$db_connect = @mysql_connect('localhost', 'eighth-d', 'mygame2468');
// the "@" is used to supress the generic function error.
if (!$db_connect) { // if value in variable is false (!)
die('Could not connect to MySQL database server, the server returned the error: '.mysql_error());
}
$db = @mysql_select_db('eighth-d_8thd');
if (!$db) { // if value in variable is false (!)
die('Could not select MySQL database, the server returned the error: '.mysql_error());
}
?>
<table width="100%">
<tr>
<td class="title"><b>Login to your admin account at 8th Dimension</b></td>
</tr>
<tr>
<?
if (!isset($HTTP_GET_VARS['do'])) {$do = "false";}
else {$do = $HTTP_GET_VARS['do'];}
if ($do == "false") {
?>
<td class="content">
<table>
<form action="index.php?act=login&do=true" method="post">
<tr><td>Username:</td><td><input type="text" name="uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="password"></td></tr>
<tr><td></td><td><input type="submit" value=" Submit "></td></tr>
</form>
</table>
</td>
<?
}
else {
$uname = $HTTP_POST_VARS['uname'];
$pass = $HTTP_POST_VARS['password'];
if ($uname == "" or $pass == "") {
echo "Sorry, You haven't fully completed your information. All fields are required. Please go <a href="#" onClick="history.back(-1);">back</a> and re-enter your information.";}
else {
$sql = "select a_uname, a_pass from admins where a_uname = $uname and a_pass = $pass";
$sql = mysql_query($sql) or die(mysql_error());
$sql = mysql_num_rows($sql);
if ($sql >= 1) {
session_register("admin_8thd");
$_SESSION["admin_uname"] = $HTTP_POST_VARS["uname"];
echo "<font color="red">You have successfully logged in as $uname!</font>";}
else {
?>
<table>
<font color="red">Your username and/or password was incorrect. Please try again. Your IP has been taken and the webmaster has been notified for security reasons.</font>
<form action="index.php?act=login&do=true" method="post">
<tr><td>Username:</td><td><input type="text" name="uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="password"></td></tr>
<tr><td></td><td><input type="submit" value=" send "></td></tr>
</form>
</table>
<? }} ?>
</center>
<?
session_start();
?>
<head>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<?php
$db_connect = @mysql_connect('localhost', 'eighth-d', 'mygame2468');
// the "@" is used to supress the generic function error.
if (!$db_connect) { // if value in variable is false (!)
die('Could not connect to MySQL database server, the server returned the error: '.mysql_error());
}
$db = @mysql_select_db('eighth-d_8thd');
if (!$db) { // if value in variable is false (!)
die('Could not select MySQL database, the server returned the error: '.mysql_error());
}
?>
<table width="100%">
<tr>
<td class="title"><b>Login to your admin account at 8th Dimension</b></td>
</tr>
<tr>
<?
if (!isset($HTTP_GET_VARS['do'])) {$do = "false";}
else {$do = $HTTP_GET_VARS['do'];}
if ($do == "false") {
?>
<td class="content">
<table>
<form action="index.php?act=login&do=true" method="post">
<tr><td>Username:</td><td><input type="text" name="uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="password"></td></tr>
<tr><td></td><td><input type="submit" value=" Submit "></td></tr>
</form>
</table>
</td>
<?
}
else {
$uname = $HTTP_POST_VARS['uname'];
$pass = $HTTP_POST_VARS['password'];
if ($uname == "" || $pass == "") {
echo "Sorry, You haven't fully completed your information. All fields are required. Please go <a href="#" onClick="history.back(-1);">back</a> and re-enter your information.";}
else {
$sql = "select a_uname, a_pass from admins where a_uname = $uname and a_pass = $pass";
$sql = mysql_query($sql) or die(mysql_error());
$sql = mysql_num_rows($sql);
if ($sql >= 1) {
session_register("admin_8thd");
$_SESSION["admin_uname"] = $HTTP_POST_VARS["uname"];
echo "<font color="red">You have successfully logged in as $uname!</font>";}
else {
?>
<table>
<font color="red">Your username and/or password was incorrect. Please try again. Your IP has been taken and the webmaster has been notified for security reasons.</font>
<form action="index.php?act=login&do=true" method="post">
<tr><td>Username:</td><td><input type="text" name="uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="password"></td></tr>
<tr><td></td><td><input type="submit" value=" send "></td></tr>
</form>
</table>
<? }} ?>
</center>
There is nothing about using or instead of ||. You may continue using or anyway (Logical Operators). There is a missing } in your code. It was opened on line 41. Just close it on line 65:
<table>
<font color="red">Your username and/or password was incorrect. Please try again. Your IP has been taken and the webmaster has been notified for security reasons.</font>
your html structure is broken. To avoid nasty sideeffects you should check this again