Jump to content

[SOLVED] Syntax error, then moving to sessions..


GameYin

Recommended Posts

 

Ok I have a login script. I have a syntax error. Once fixed we will be moving onto displaying certain links if they are signed on. I have taken advice and moved to sessions.

 

Here is the website

www.gameyin.com/index.php

 

Here is the code relating to it. In index.php.

 

<?php
session_start();
$n=$_SESSION['n'];
?>
BLAH BLAH  MORE CODING STUFF
<b><a class="add" href="index.php">Home</a></b> 
if (empty($_SESSION['n'])) { ?>
        <a href="register.php">Register</a>
        <a href="login.php">Login</a>
<? }else{ ?>
        <a href="logout.php">Logout</a>
        <a href="usercp/index.php">UserCP</a>
<? 
}
?>

 

The }else{ is line 26.

Also, I want register/login to display if not signed on, vice versa for logout/usercp. Help?

Link to comment
Share on other sites

Trying to "high-tech" my error messages. Look now...

Here's whole code for login.php

 

 

<?php
session_start();
include 'config.php';
$n=$_SESSION['n'];
if(isset($_POST['login']))
{

$username = trim(addslashes($_POST['username']));
$password = md5(trim($_POST['password']));

$query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error());

$row = mysql_fetch_array($query);

// now we check if they are activated

if(mysql_num_rows($query) > 0)
{

if($row['Activated'] > 0)
{

$_SESSION['s_logged_n'] = 'true';
$_SESSION['s_username'] = $username;
$_SESSION['s_name'] = $row['Name'];

header("Location: index.php");

} elseif ($row['Activated'] != 1) {

echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Error in login | DevPlooth.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="Find webmasters, web designers, SEO techs,  web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources.  Our forum  provides a way for people to find  web help and support!" />
    <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing,  seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="body-container">
	<div class="body-outer" id="body-outer">
		<div class="body-header">
			<div class="logo">
<a href="#">DevPlooth.com</a><br />
<small>Forums | Arcade | Tutorials | Web Hosting |</small>
</div>
   		<div class="tmenu">
<b><a class="add" href="index.php">Home</a></b> 
<? if (empty($_SESSION['n'])) { ?>
        <a href="register.php">Register</a>
        <a href="login.php">Login</a>
<? }else{ ?>
        <a href="logout.php">Logout</a>
        <a href="usercp/index.php">UserCP</a>
<? 
}
?>
        <a href="arcade/index.php">Arcade</a>  
<a href="tutorials/index.php">Tutorials</a> 
<a href="forums/index.php">Forums</a>
<a href="proxy/index.php">Proxy</a> 
	</div>
		<div class="search">
     <form action="search.php" method="post" style="display:inline;">
		<div>
<input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" />
<input type="image" src="images/search.gif" /></div>
</form>
</div>
</div>
</div>
</div>
<div class="navbar">
<small>Please browse our tutorials in many languages!</small>
<br />
<table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr>
<tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr>
<tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr>
<tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr>
<tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr>
<tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr>
<tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr>
<tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr>
<tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr>
<tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr>
<tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr>
<tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr>
<tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr>
<tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr>
<tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr>
<tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr>
<tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr>
<tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr>
</table>
</div>
<div class="error"><p>Sorry, you must activate your account first. Please check your email for the email. OR, you entered invalid details <a href="login.php">Try again.</a></p>
<p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div>
<div id="footer">
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a>
© 2008-2009 DevPlooth.com. All rights reserved
<a href="http://jigsaw.w3.org/css-validator/">
    <img style="border:0;width:70px;height:25px"
        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
        alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>
';
} else {

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Error in login | DevPlooth.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="Find webmasters, web designers, SEO techs,  web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources.  Our forum  provides a way for people to find  web help and support!" />
    <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing,  seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="body-container">
	<div class="body-outer" id="body-outer">
		<div class="body-header">
			<div class="logo">
<a href="#">DevPlooth.com</a><br />
<small>Forums | Arcade | Tutorials | Web Hosting |</small>
</div>
   		<div class="tmenu">
<b><a class="add" href="index.php">Home</a></b> 
<? if (empty($_SESSION['n'])) { ?>
        <a href="register.php">Register</a>
        <a href="login.php">Login</a>
<? }else{ ?>
        <a href="logout.php">Logout</a>
        <a href="usercp/index.php">UserCP</a>
<? 
}
?>
        <a href="arcade/index.php">Arcade</a>  
<a href="tutorials/index.php">Tutorials</a> 
<a href="forums/index.php">Forums</a>
<a href="proxy/index.php">Proxy</a> 
	</div>
		<div class="search">
     <form action="search.php" method="post" style="display:inline;">
		<div>
<input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" />
<input type="image" src="images/search.gif" /></div>
</form>
</div>
</div>
</div>
</div>
<div class="navbar">
<small>Please browse our tutorials in many languages!</small>
<br />
<table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr>
<tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr>
<tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr>
<tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr>
<tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr>
<tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr>
<tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr>
<tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr>
<tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr>
<tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr>
<tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr>
<tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr>
<tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr>
<tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr>
<tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr>
<tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr>
<tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr>
<tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr>
</table>
</div>
<div class="error">
<p>You must login to view this page. Enter your username and password below and hit submit:</p>
<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
<p>Username:<br>
<input name="username" type="text" Cid="username">

<p>Password:<br>
<input name="password" type="password" id="password">
</p>
<p>
<input name="login" type="submit" id="login" value="Submit">
</p>
</form>
<p>Didn't get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p>
<p>Need an account? <a href="register.php">Click here</a> to register, it's completely free! </p></div>
<div id="footer">
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a>
© 2008-2009 DevPlooth.com. All rights reserved
<a href="http://jigsaw.w3.org/css-validator/">
    <img style="border:0;width:70px;height:25px"
        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
        alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>
<? 
}
mysql_close($l);
?>

Link to comment
Share on other sites

I added 2 }'s but still a syntax error. And I don't think it's unreadable. I can read it quite fine.

 

Ok, I changed my code to...

 

<?php
session_start();
include 'config.php';
$n=$_SESSION['n'];
if(isset($_POST['login']))
{

$username = trim(addslashes($_POST['username']));
$password = md5(trim($_POST['password']));

$query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error());

$row = mysql_fetch_array($query);

// now we check if they are activated

if(mysql_num_rows($query) > 0)
{

if($row['Activated'] > 0)
{

$_SESSION['s_logged_n'] = 'true';
$_SESSION['s_username'] = $username;
$_SESSION['s_name'] = $row['Name'];

header("Location: index.php");

} elseif ($row['Activated'] != 1) { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Error in login | DevPlooth.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="Find webmasters, web designers, SEO techs,  web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources.  Our forum  provides a way for people to find  web help and support!" />
    <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing,  seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="body-container">
	<div class="body-outer" id="body-outer">
		<div class="body-header">
			<div class="logo">
<a href="index.php">DevPlooth.com</a><br />
<small>Forums | Arcade | Tutorials | Web Hosting |</small>
</div>
   		<div class="tmenu">
<b><a class="add" href="index.php">Home</a></b> 
<? if (empty($_SESSION['n'])) { ?>
        <a href="register.php">Register</a>
        <a href="login.php">Login</a>
<? }else{ ?>
        <a href="logout.php">Logout</a>
        <a href="usercp/index.php">UserCP</a>
<? 
}
?>
        <a href="arcade/index.php">Arcade</a>  
<a href="tutorials/index.php">Tutorials</a> 
<a href="forums/index.php">Forums</a>
<a href="proxy/index.php">Proxy</a> 
	</div>
		<div class="search">
     <form action="search.php" method="post" style="display:inline;">
		<div>
<input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" />
<input type="image" src="images/search.gif" /></div>
</form>
</div>
</div>
</div>
</div>
<div class="navbar">
<small>Please browse our tutorials in many languages!</small>
<br />
<table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr>
<tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr>
<tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr>
<tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr>
<tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr>
<tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr>
<tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr>
<tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr>
<tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr>
<tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr>
<tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr>
<tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr>
<tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr>
<tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr>
<tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr>
<tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr>
<tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr>
<tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr>
</table>
</div>
<div class="error"><p>Sorry, you must activate your account first. Please check your email for the email. OR, you entered invalid details <a href="login.php">Try again.</a></p>
<p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div>
<div id="footer">
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a>
© 2008-2009 DevPlooth.com. All rights reserved
<a href="http://jigsaw.w3.org/css-validator/">
    <img style="border:0;width:70px;height:25px"
        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
        alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>
<? } else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Error in login | DevPlooth.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="Find webmasters, web designers, SEO techs,  web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources.  Our forum  provides a way for people to find  web help and support!" />
    <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing,  seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="body-container">
	<div class="body-outer" id="body-outer">
		<div class="body-header">
			<div class="logo">
<a href="index.php">DevPlooth.com</a><br />
<small>Forums | Arcade | Tutorials | Web Hosting |</small>
</div>
   		<div class="tmenu">
<b><a class="add" href="index.php">Home</a></b> 
<? if (empty($_SESSION['n'])) { ?>
        <a href="register.php">Register</a>
        <a href="login.php">Login</a>
<? }else{ ?>
        <a href="logout.php">Logout</a>
        <a href="usercp/index.php">UserCP</a>
<? 
}
?>
        <a href="arcade/index.php">Arcade</a>  
<a href="tutorials/index.php">Tutorials</a> 
<a href="forums/index.php">Forums</a>
<a href="proxy/index.php">Proxy</a> 
	</div>
		<div class="search">
     <form action="search.php" method="post" style="display:inline;">
		<div>
<input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" />
<input type="image" src="images/search.gif" /></div>
</form>
</div>
</div>
</div>
</div>
<div class="navbar">
<small>Please browse our tutorials in many languages!</small>
<br />
<table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr>
<tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr>
<tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr>
<tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr>
<tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr>
<tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr>
<tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr>
<tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr>
<tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr>
<tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr>
<tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr>
<tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr>
<tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr>
<tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr>
<tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr>
<tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr>
<tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr>
<tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr>
</table>
</div>
<div class="error">
<p>You must login to view this page. Enter your username and password below and hit submit:</p>
<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
<p>Username:<br>
<input name="username" type="text" Cid="username">

<p>Password:<br>
<input name="password" type="password" id="password">
</p>
<p>
<input name="login" type="submit" id="login" value="Submit">
</p>
</form>
<p>Didn't get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p>
<p>Need an account? <a href="register.php">Click here</a> to register, it's completely free! </p></div>
<div id="footer">
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a>
© 2008-2009 DevPlooth.com. All rights reserved
<a href="http://jigsaw.w3.org/css-validator/">
    <img style="border:0;width:70px;height:25px"
        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
        alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>
<? 
}
}
}
mysql_close($l);
?>

 

But now nothing shows up.

 

www.gameyin.com/login.php

Link to comment
Share on other sites

try:

 

<?php
session_start();
$n=$_SESSION['n'];
?>
BLAH BLAH  MORE CODING STUFF
<b><a class="add" href="index.php">Home</a></b> 

<?php
if (empty($_SESSION['n'])) { ?>
        <a href="register.php">Register</a>
        <a href="login.php">Login</a>
<?php }else{ ?>
        <a href="logout.php">Logout</a>
        <a href="usercp/index.php">UserCP</a>
<?php
}
?>

Link to comment
Share on other sites

You may be able to read your code, it was written by you afterall. Then again... you don't seem to have any overview of what's going on. Not to mention how hard it is for others to read.

 

Also, I think

 

if(isset($_POST['login']))

 

is pretty much the reason why nothing shows up.

Link to comment
Share on other sites

Your closing braces are in the wrong place. ALL of your code (well, bar the first 5 lines) is inside the first if statement. This is why it was not just a simple matter of adding in the closing brackets.

 

You need to go through your code very carefully, and make sense of what it is supposed to be doing where.

Link to comment
Share on other sites

Ok, changed things up a bit..Now I have a syntax error again...www.gameyin.com/login.php

 

<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login | DevPlooth.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="Find webmasters, web designers, SEO techs,  web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources.  Our forum  provides a way for people to find  web help and support!" />
    <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing,  seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="body-container">
	<div class="body-outer" id="body-outer">
		<div class="body-header">
			<div class="logo">
<a href="index.php">DevPlooth.com</a><br />
<small>Forums | Arcade | Tutorials | Web Hosting |</small>
</div>
   		<div class="tmenu">
<b><a class="add" href="index.php">Home</a></b> 
<? if (empty($_SESSION['n'])) { ?>
        <a href="register.php">Register</a>
        <a href="login.php">Login</a>
<? }else{ ?>
        <a href="logout.php">Logout</a>
        <a href="usercp/index.php">UserCP</a>
<? 
}
?>
        <a href="arcade/index.php">Arcade</a>  
<a href="tutorials/index.php">Tutorials</a> 
<a href="forums/index.php">Forums</a>
<a href="proxy/index.php">Proxy</a> 
	</div>
		<div class="search">
     <form action="search.php" method="post" style="display:inline;">
		<div>
<input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" />
<input type="image" src="images/search.gif" /></div>
</form>
</div>
</div>
</div>
</div>
<div class="navbar">
<small>Please browse our tutorials in many languages!</small>
<br />
<table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr>
<tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr>
<tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr>
<tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr>
<tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr>
<tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr>
<tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr>
<tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr>
<tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr>
<tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr>
<tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr>
<tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr>
<tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr>
<tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr>
<tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr>
<tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr>
<tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr>
<tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr>
</table>
</div>
<?php
include 'config.php';
$n=$_SESSION['n'];
if(isset($_POST['login']))
{

$username = trim(addslashes($_POST['username']));
$password = md5(trim($_POST['password']));

$query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error());

$row = mysql_fetch_array($query);

// now we check if they are activated

if(mysql_num_rows($query) > 0)
{

if($row['Activated'] > 0)
{

$_SESSION['s_logged_n'] = 'true';
$_SESSION['s_username'] = $username;
$_SESSION['s_name'] = $row['Name'];

header("Location: index.php");

} elseif ($row['Activated'] != 1) {
echo '
<div class="error"><p>Sorry, you must activate your account first. Please check your email for the email. OR, you entered invalid details <a href="login.php">Try again.</a></p>
<p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div>
<div id="footer">
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a>
© 2008-2009 DevPlooth.com. All rights reserved
<a href="http://jigsaw.w3.org/css-validator/">
    <img style="border:0;width:70px;height:25px"
        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
        alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>
<? } else {
echo '
<div class="error">
<p>You must login to view this page. Enter your username and password below and hit submit:</p>
<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
<p>Username:<br>
<input name="username" type="text" Cid="username">

<p>Password:<br>
<input name="password" type="password" id="password">
</p>
<p>
<input name="login" type="submit" id="login" value="Submit">
</p>
</form>
<p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p>
<p>Need an account? <a href="register.php">Click here</a> to register, its completely free! </p></div>
<div id="footer">
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a>
© 2008-2009 DevPlooth.com. All rights reserved
<a href="http://jigsaw.w3.org/css-validator/">
    <img style="border:0;width:70px;height:25px"
        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
        alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>
<? 
}
}
}
mysql_close($l);
?>

Link to comment
Share on other sites

I did all the changes, still syntax error. Here is the updated code

 

<?php
session_start();
include 'config.php';
$n=$_SESSION['n'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login | DevPlooth.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="Find webmasters, web designers, SEO techs,  web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources.  Our forum  provides a way for people to find  web help and support!" />
    <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing,  seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="body-container">
	<div class="body-outer" id="body-outer">
		<div class="body-header">
			<div class="logo">
<a href="index.php">DevPlooth.com</a><br />
<small>Forums | Arcade | Tutorials | Web Hosting |</small>
</div>
   		<div class="tmenu">
<b><a class="add" href="index.php">Home</a></b> 
<? if (empty($_SESSION['n'])) { ?>
        <a href="register.php">Register</a>
        <a href="login.php">Login</a>
<? }else{ ?>
        <a href="logout.php">Logout</a>
        <a href="usercp/index.php">UserCP</a>
<? 
}
?>
        <a href="arcade/index.php">Arcade</a>  
<a href="tutorials/index.php">Tutorials</a> 
<a href="forums/index.php">Forums</a>
<a href="proxy/index.php">Proxy</a> 
	</div>
		<div class="search">
    <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> style="display:inline;">
		<div>
<input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" />
<input type="image" src="images/search.gif" /></div>
</form>
</div>
</div>
</div>
</div>
<div class="navbar">
<small>Please browse our tutorials in many languages!</small>
<br />
<table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr>
<tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr>
<tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr>
<tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr>
<tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr>
<tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr>
<tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr>
<tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr>
<tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr>
<tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr>
<tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr>
<tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr>
<tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr>
<tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr>
<tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr>
<tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr>
<tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr>
<tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr>
</table>
</div>
<?php
if(isset($_POST['login']))
{

$username = trim(addslashes($_POST['username']));
$password = md5(trim($_POST['password']));

$query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error());

$row = mysql_fetch_array($query);

// now we check if they are activated

if(mysql_num_rows($query) > 0)
{

if($row['Activated'] > 0)
{

$_SESSION['s_logged_n'] = 'true';
$_SESSION['s_username'] = $username;
$_SESSION['s_name'] = $row['Name'];

header("Location: index.php");

} elseif ($row['Activated'] != 1) {
echo '
<div class="error"><p>Sorry, you must activate your account first. Please check your email for the email. OR, you entered invalid details <a href="login.php">Try again.</a></p>
<p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div>
<div id="footer">
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a>
© 2008-2009 DevPlooth.com. All rights reserved
<a href="http://jigsaw.w3.org/css-validator/">
    <img style="border:0;width:70px;height:25px"
        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
        alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>
} else {
echo '
<div class="error">
<p>You must login to view this page. Enter your username and password below and hit submit:</p>
<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
<p>Username:<br>
<input name="username" type="text" Cid="username">

<p>Password:<br>
<input name="password" type="password" id="password">
</p>
<p>
<input name="login" type="submit" id="login" value="Submit">
</p>
</form>
<p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p>
<p>Need an account? <a href="register.php">Click here</a> to register, its completely free! </p></div>
<div id="footer">
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a>
© 2008-2009 DevPlooth.com. All rights reserved
<a href="http://jigsaw.w3.org/css-validator/">
    <img style="border:0;width:70px;height:25px"
        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
        alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>';
}
}
}
mysql_close($l);
?>

Link to comment
Share on other sites

Ok, there was 1 more syntax error like that one, fixed it. Thanks. Though www.gameyin.com/login.php

 

Form doesn't show up. And I'm not logged on.

<?php
session_start();
include 'config.php';
$n=$_SESSION['n'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login | DevPlooth.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="Find webmasters, web designers, SEO techs,  web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources.  Our forum  provides a way for people to find  web help and support!" />
    <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing,  seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="body-container">
	<div class="body-outer" id="body-outer">
		<div class="body-header">
			<div class="logo">
<a href="index.php">DevPlooth.com</a><br />
<small>Forums | Arcade | Tutorials | Web Hosting |</small>
</div>
   		<div class="tmenu">
<b><a class="add" href="index.php">Home</a></b> 
<? if (empty($_SESSION['n'])) { ?>
        <a href="register.php">Register</a>
        <a href="login.php">Login</a>
<? }else{ ?>
        <a href="logout.php">Logout</a>
        <a href="usercp/index.php">UserCP</a>
<? 
}
?>
        <a href="arcade/index.php">Arcade</a>  
<a href="tutorials/index.php">Tutorials</a> 
<a href="forums/index.php">Forums</a>
<a href="proxy/index.php">Proxy</a> 
	</div>
		<div class="search">
    <form method="post" action="login.php" style="display:inline;">
		<div>
<input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" />
<input type="image" src="images/search.gif" /></div>
</form>
</div>
</div>
</div>
</div>
<div class="navbar">
<small>Please browse our tutorials in many languages!</small>
<br />
<table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr>
<tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr>
<tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr>
<tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr>
<tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr>
<tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr>
<tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr>
<tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr>
<tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr>
<tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr>
<tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr>
<tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr>
<tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr>
<tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr>
<tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr>
<tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr>
<tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr>
<tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr>
</table>
</div>
<?php
if(isset($_POST['login']))
{

$username = trim(addslashes($_POST['username']));
$password = md5(trim($_POST['password']));

$query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error());

$row = mysql_fetch_array($query);

// now we check if they are activated

if(mysql_num_rows($query) > 0)
{

if($row['Activated'] > 0)
{

$_SESSION['s_logged_n'] = 'true';
$_SESSION['s_username'] = $username;
$_SESSION['s_name'] = $row['Name'];

header("Location: index.php");

} elseif ($row['Activated'] != 1) {
echo '
<div class="error"><p>Sorry, you must activate your account first. Please check your email for the email. OR, you entered invalid details <a href="login.php">Try again.</a></p>
<p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div>
<div id="footer">
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a>
© 2008-2009 DevPlooth.com. All rights reserved
<a href="http://jigsaw.w3.org/css-validator/">
    <img style="border:0;width:70px;height:25px"
        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
        alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>';
} else {
echo '
<div class="error">
<p>You must login to view this page. Enter your username and password below and hit submit:</p>
<form method="post" action="login.php">
<p>Username:<br>
<input name="username" type="text" Cid="username">

<p>Password:<br>
<input name="password" type="password" id="password">
</p>
<p>
<input name="login" type="submit" id="login" value="Submit">
</p>
</form>
<p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p>
<p>Need an account? <a href="register.php">Click here</a> to register, its completely free! </p></div>
<div id="footer">
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a>
© 2008-2009 DevPlooth.com. All rights reserved
<a href="http://jigsaw.w3.org/css-validator/">
    <img style="border:0;width:70px;height:25px"
        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
        alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>';
}
}
}
mysql_close($l);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.