Jump to content

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


GameYin

Recommended Posts

Ok, well give help me figure this out? Great advice, but I don't know how to position. Someone help? I've tried everything I can think of and I still lose.

 

Edit: Ok, I positioned it differently, now it will ONLY display what you see on www.gameyin.com/login.php

 

code now

 

<?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="get" action="search.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, either you entered invalid login details, or you must activate your account first. Please check your email for the email. <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

I think, that it may have something to do with this..I kinda played around with putting this in, so I think the elseif statement here is messing it up..

 

} elseif ($row['Activated'] != 1){
echo '
<div class="error"><p>Sorry, either you entered invalid login details, or you must activate your account first. Please check your email for the email. <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>';
}

 

Ok, so thinking it through, it will always show that message because as a guest, logically, I am not an activated user, so I am going to mess w/ the statement. What else kind of if statement should I put in there.

 

@ Boom.dk, I do understand my code, I figured out that stuff on my own. Moving the HTML makes it harder for me.

Link to comment
Share on other sites

I'm not done yet, I need a new if statement in there ;o. Lol. I don't know what else I should do. Because I don't think I need them activated to view that...I could have a die message for that, once they try to login...So any ideas on a new if statement?

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.