Jump to content

What's Wrong With My Code?


PureReactionUK

Recommended Posts

Sorry for the amount of code below this is one full page. Ok, when I try to login to the member section it wont let me. I can succesfully register and have made sure that the data is there in MySQL. Every time I try to login the page just refreshes. Oh and I am new here.

 

I think it has something to do with the (header("Location: http://www.PureReactionUK.com/member.php/");

exit;)? I could be wrong.

 

Here is my code:

<?php
session_start();
include 'config.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);
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: http://www.PureReactionUK.com/member.php/");
exit;
} else {
echo '
<!DOCTYPE HTML>
<html>

<head>
  <title>PureReactionUK - Home</title>
  <link rel="shortcut icon" href="images/favicon.ico">
  <meta name="description" content="Here you will find a tone of things that you will find very helpfull." />
  <meta name="keywords" content="Pure,Reaction,UK,HD,BD,x,Brutal,Democracy,iPad,iPhone,iPod,Theme,WinetrBoard,iOS,Hack,Mod,Cydia,Surik,Apple,Game,Apps,USB,Fix,Restore,Design,SummerBoard,Playstation,3,Xbox,360,MineCraft,Server,Call,Of,Duty,Modern,Warfare,2,3,4,5,6,7,8,9,Black,Ops,Icons,Zombies,Jtag,SSH,iFile,HTML,Jailbreak,CSS,Javascript,Craig,Stewart,YouTube,Music,Downloads,Servers,Bukkit,MCAdmin,Tiny,Umbrella,GreenpoisOn,SpringBoard,Windows,Microsoft,XP,Vista" />
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="javascript/rollover.js" type="text/javascript"></script>
<style type="text/css">
body,td,th {
font-family: "trebuchet ms", arial, sans-serif;
font-size: 0.8em;
}
a:link {
color: #09F;
}
</style>
</head>

<body>
  <div id="main">
    <div id="header">
      <div id="logo">
        <div id="logo_text">
          <h1><a href="index.html">PureReaction<span class="logo_colour">UK</span></a></h1>
          <h2>All You Need To Know Is Here, Have A Look</h2>
        </div>
      </div>
      <div id="menubar">
        <ul id="menu">
          <li class="selected"><a href="index.html" title="Home" target="_self">Home</a></li>
          <li><a href="tutorials.html" title="Tutorials" target="_self">Tutorials</a></li>
          <li><a href="downloads.html" title="Downloads" target="_self">Downloads</a></li>
          <li><a href="register.html" title="Register" target="_self">Register</a></li>
          <li><a href="login.html" title="Log In" target="_self">Log In</a></li>
        </ul>
      </div>
    </div>
    <div id="content_header"></div>
    <div id="site_content">
      <div class="sidebar">
        <h3>Latest Updates</h3>
        <h4> Website Launched</h4>
        <h5>January 1st, 2010</h5>
        <p>Take a good look around and take your time there is alot of content to explore. <br />
        <a href="index.html" title="Home" target="_self">Read more</a></p>
        <p></p>
        <h4>New Downloads</h4>
        <h5>January 1st, 2010</h5>
        <p>Check out the latest downloads by clicking the link below. Remember you must sign up / sign in.<br />
        <a href="downloads.html" title="Downloads" target="_self">Read more</a></p>
        <h3>Useful Links</h3>
        <ul>
          <li><a href="http://www.minecraft.net/" title="MineCraft" target="_blank">MineCraft</a></li>
          <li><a href="http://modmyi.com/" title="ModMyi" target="_blank">ModMyi</a></li>
          <li><a href="http://www.ifans.com/" title="iFans" target="_blank">iFans</a>
            <ul>
              <li><a href="http://www.minecraftforum.net/" title="MineCraft Forum" target="_blank">MineCraft - Forum</a></li>
            </ul>
          </li>
        </ul>
      </div>
      <div id="content">
        <h1>Log In Here</h1><div id="error"><p>Sorry, you must activate your account first. Please check your email for the email.</p>
<p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div> </p>
      </div>
    </div>
    <div id="content_footer"></div>
    <div id="footer">
    Copyright © All Rights Reserved By <a href="http://www.purereactionuk.com/" title="PureReactionUK" target="_self">www.PureReactionuk.com</a> - 2011</div>
  </div>
</body>
</html>
';

}

} else {

echo '
<html>

<head>
  <title>PureReactionUK - Home</title>
  <link rel="shortcut icon" href="images/favicon.ico">
  <meta name="description" content="Here you will find a tone of things that you will find very helpfull." />
  <meta name="keywords" content="Pure,Reaction,UK,HD,BD,x,Brutal,Democracy,iPad,iPhone,iPod,Theme,WinetrBoard,iOS,Hack,Mod,Cydia,Surik,Apple,Game,Apps,USB,Fix,Restore,Design,SummerBoard,Playstation,3,Xbox,360,MineCraft,Server,Call,Of,Duty,Modern,Warfare,2,3,4,5,6,7,8,9,Black,Ops,Icons,Zombies,Jtag,SSH,iFile,HTML,Jailbreak,CSS,Javascript,Craig,Stewart,YouTube,Music,Downloads,Servers,Bukkit,MCAdmin,Tiny,Umbrella,GreenpoisOn,SpringBoard,Windows,Microsoft,XP,Vista" />
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="javascript/rollover.js" type="text/javascript"></script>
<style type="text/css">
body,td,th {
font-family: "trebuchet ms", arial, sans-serif;
font-size: 0.8em;
}
a:link {
color: #09F;
}
</style>
</head>

<body>
  <div id="main">
    <div id="header">
      <div id="logo">
        <div id="logo_text">
          <h1><a href="index.html">PureReaction<span class="logo_colour">UK</span></a></h1>
          <h2>All You Need To Know Is Here, Have A Look</h2>
        </div>
      </div>
      <div id="menubar">
        <ul id="menu">
          <li class="selected"><a href="index.html" title="Home" target="_self">Home</a></li>
          <li><a href="tutorials.html" title="Tutorials" target="_self">Tutorials</a></li>
          <li><a href="downloads.html" title="Downloads" target="_self">Downloads</a></li>
          <li><a href="register.html" title="Register" target="_self">Register</a></li>
          <li><a href="login.html" title="Log In" target="_self">Log In</a></li>
        </ul>
      </div>
    </div>
    <div id="content_header"></div>
    <div id="site_content">
      <div class="sidebar">
        <h3>Latest Updates</h3>
        <h4> Website Launched</h4>
        <h5>January 1st, 2010</h5>
        <p>Take a good look around and take your time there is alot of content to explore. <br />
        <a href="index.html" title="Home" target="_self">Read more</a></p>
        <p></p>
        <h4>New Downloads</h4>
        <h5>January 1st, 2010</h5>
        <p>Check out the latest downloads by clicking the link below. Remember you must sign up / sign in.<br />
        <a href="downloads.html" title="Downloads" target="_self">Read more</a></p>
        <h3>Useful Links</h3>
        <ul>
          <li><a href="http://www.minecraft.net/" title="MineCraft" target="_blank">MineCraft</a></li>
          <li><a href="http://modmyi.com/" title="ModMyi" target="_blank">ModMyi</a></li>
          <li><a href="http://www.ifans.com/" title="iFans" target="_blank">iFans</a>
            <ul>
              <li><a href="http://www.minecraftforum.net/" title="MineCraft Forum" target="_blank">MineCraft - Forum</a></li>
            </ul>
          </li>
        </ul>
      </div>
      <div id="content">
        <h1>Log In Here</h1><div id="error"><p>There was an error processing your login, it appears that your username and/or password was incorrect. Please try again.</p>
<p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p>

</div>
    </div>
    <div id="content_footer"></div>
    <div id="footer">
    Copyright © All Rights Reserved By <a href="http://www.purereactionuk.com/" title="PureReactionUK" target="_self">www.PureReactionuk.com</a> - 2011</div>
  </div>
</body>
</html>
';

}

} else {

?>
<html>

<head>
  <title>PureReactionUK - Home</title>
  <link rel="shortcut icon" href="images/favicon.ico">
  <meta name="description" content="Here you will find a tone of things that you will find very helpfull." />
  <meta name="keywords" content="Pure,Reaction,UK,HD,BD,x,Brutal,Democracy,iPad,iPhone,iPod,Theme,WinetrBoard,iOS,Hack,Mod,Cydia,Surik,Apple,Game,Apps,USB,Fix,Restore,Design,SummerBoard,Playstation,3,Xbox,360,MineCraft,Server,Call,Of,Duty,Modern,Warfare,2,3,4,5,6,7,8,9,Black,Ops,Icons,Zombies,Jtag,SSH,iFile,HTML,Jailbreak,CSS,Javascript,Craig,Stewart,YouTube,Music,Downloads,Servers,Bukkit,MCAdmin,Tiny,Umbrella,GreenpoisOn,SpringBoard,Windows,Microsoft,XP,Vista" />
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="javascript/rollover.js" type="text/javascript"></script>
<style type="text/css">
body,td,th {
font-family: "trebuchet ms", arial, sans-serif;
font-size: 0.8em;
}
a:link {
color: #09F;
}
</style>
</head>

<body>
  <div id="main">
    <div id="header">
      <div id="logo">
        <div id="logo_text">
          <h1><a href="index.html">PureReaction<span class="logo_colour">UK</span></a></h1>
          <h2>All You Need To Know Is Here, Have A Look</h2>
        </div>
      </div>
      <div id="menubar">
        <ul id="menu">
          <li class="selected"><a href="index.html" title="Home" target="_self">Home</a></li>
          <li><a href="tutorials.html" title="Tutorials" target="_self">Tutorials</a></li>
          <li><a href="downloads.html" title="Downloads" target="_self">Downloads</a></li>
          <li><a href="register.php" title="Register" target="_self">Register</a></li>
          <li><a href="login.php" title="Log In" target="_self">Log In</a></li>
        </ul>
      </div>
    </div>
    <div id="content_header"></div>
    <div id="site_content">
      <div class="sidebar">
        <h3>Latest Updates</h3>
        <h4> Website Launched</h4>
        <h5>January 1st, 2010</h5>
        <p>Take a good look around and take your time there is alot of content to explore. <br />
        <a href="index.html" title="Home" target="_self">Read more</a></p>
        <p></p>
        <h4>New Downloads</h4>
        <h5>January 1st, 2010</h5>
        <p>Check out the latest downloads by clicking the link below. Remember you must sign up / sign in.<br />
        <a href="downloads.html" title="Downloads" target="_self">Read more</a></p>
        <h3>Useful Links</h3>
        <ul>
          <li><a href="http://www.minecraft.net/" title="MineCraft" target="_blank">MineCraft</a></li>
          <li><a href="http://modmyi.com/" title="ModMyi" target="_blank">ModMyi</a></li>
          <li><a href="http://www.ifans.com/" title="iFans" target="_blank">iFans</a>
            <ul>
              <li><a href="http://www.minecraftforum.net/" title="MineCraft Forum" target="_blank">MineCraft - Forum</a></li>
            </ul>
          </li>
        </ul>
      </div>
      <div id="content">
        <h1>Log In Here</h1><form name="login_now" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
          <table width="589" border="0">
            <tr>
              <td width="116">Username</td>
              <td width="258"><label for="username"></label>
              <input type="text" name="username" id="username"></td>
              <td width="201"> </td>
            </tr>
            <tr>
              <td>Password</td>
              <td><label for="date"></label>
                <input type="password" name="password" id="password">
              <label for="date"></label></td>
              <td> </td>
            </tr>
            <tr>
              <td> </td>
              <td><input type="submit" name="submit" id="submit" value="Submit">
              <input type="reset" name="reset" id="reset" value="Reset"></td>
              <td> </td>
            </tr>
          </table>
        </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> </p>
</div>
    </div>
    <div id="content_footer"></div>
    <div id="footer">
    Copyright © All Rights Reserved By <a href="http://www.purereactionuk.com/" title="PureReactionUK" target="_self">www.PureReactionuk.com</a> - 2011</div>
  </div>
</body>
</html>
<? } mysql_close($l); ?>

Link to comment
Share on other sites

Yes I have this snippet at the top.

 

<?php
session_start();
if($_SESSION['s_logged_n'] == 'true'){
include 'process.php';
?>

 

I am using process.php to check my authentication.

 

<?php

include 'config.php';

if(isset($_POST['changepassword']))
{

$current = trim($_POST['current']);
$new = trim($_POST['new']);
$confirm = trim($_POST['confirm']);

$pw = md5($current);

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

if(mysql_num_rows($query) > 0)
{

while($row = mysql_fetch_array($query))
{ 

if ( $_POST['new'] == $_POST['confirm'] )
{}else{

echo '<script>alert("Your passwords were not the same, please enter the same password in each field.");</script>';
echo '<script>history.back(1);</script>';
exit;

}

$password = md5($new);

$do = mysql_query("UPDATE Users SET Password = '$password' WHERE Password = '$pw' LIMIT 1") or die(mysql_error());
$dotwo = mysql_query("UPDATE Users SET Activated = 0 WHERE Password = '$password' LIMIT 1") or die(mysql_error());
$send = mail($row['Email'] , "Password changed" , "Your password has been changed to: ".trim($_POST['new'])."\n\nYou can change it again via the members only panel, but first you must re-activate your account:\nhttp://PureReactionUK.com/activate.php?id=".$row['Actkey']."\n\nDo not reply to this email, it is automated. Thanks." , "From: auto@mailer.com");

if((($do)&&($dotwo)&&($send)))
{

echo '<script>alert("Password changed. You will now be logged out and you must re-activate your account, check your email, a confirmation email has been sent.");</script>';
echo '<script>location.replace("logout.php");</script>';

exit;

} else {

echo '<script>alert("There appears to have been an error in the script. 1 or 2 of 3 things may have happened:\n\n• Your password could have been reset/changed\n• Your account could have been deactivated, see the resend validation email page\n• Your email may not have been sent.\n\nYou will now be logged out, if you are not able to login, reset your password using the form, or resend the validation email to activate your account again.\n\nWe are sorry for the inconvenience.");</script>';
echo '<script>location.replace("logout.php");</script>';

exit;

}

}

} else {

echo '<script>alert("Incorrect password.");</script>';
echo '<script>history.back(1);</script>';
exit;

}

}

if(isset($_POST['changeemail']))
{

$current = trim($_POST['current']);
$new = trim($_POST['new']);
$confirm = trim($_POST['confirm']);

$query = mysql_query("SELECT * FROM Users WHERE Email = '$current' LIMIT 1") or die(mysql_error());

if(mysql_num_rows($query) > 0)
{

while($row = mysql_fetch_array($query))
{ 

if ( $_POST['new'] == $_POST['confirm'] )
{}else{

echo '<script>alert("Your email addresses were not the same, please enter the same email to confirm.");</script>';
echo '<script>history.back(1);</script>';
exit;

}

$do = mysql_query("UPDATE Users SET Email = '$new' WHERE Email = '$current' LIMIT 1") or die(mysql_error());
$dotwo = mysql_query("UPDATE Users SET Activated = 0 WHERE Email = '$new' LIMIT 1") or die(mysql_error());
$send = mail($row['Email'] , "Email changed" , "Your email has been changed to: ".trim($_POST['new'])."\n\nYou can change it again via the members only panel, but first you must re-activate your account:\nhttp://PureReactionUK.com/activate.php?id=".$row['Actkey']."\n\nDo not reply to this email, it is automated. Thanks." , "From: auto@mailer.com");

if((($do)&&($dotwo)&&($send)))
{

echo '<script>alert("Email changed. You will now be logged out and you must re-activate your account, check your email, a confirmation email has been sent.");</script>';
echo '<script>location.replace("logout.php");</script>';

exit;

} else {

echo '<script>alert("There appears to have been an error in the script. 1 or 2 of 3 things may have happened:\n\n• Your email could have been reset/changed\n• Your account could have been deactivated, see the resend validation email page\n• Your email may not have been sent.\n\nYou will now be logged out, if you are unable to login or cannot resend the validation email to either addresses, please contact the administrator.\n\nWe are sorry for the inconvenience.");</script>';
echo '<script>location.replace("logout.php");</script>';

exit;

}

}

} else {

echo '<script>alert("Incorrect email.");</script>';
echo '<script>history.back(1);</script>';
exit;

}

}

if(isset($_POST['closeaccount']))
{

$username = $_SESSION['s_username'];

$do = mysql_query("DELETE FROM Users WHERE Username = '$username' LIMIT 1") or die(mysql_error());

if($do){

echo '<script>alert("Your account has now been closed, thank you for being with us. You will now be logged out.");</script>';
echo '<script>location.replace("logout.php");</script>';

exit;

} else {

echo '<script>alert("Your account has NOT been closed, there was an error in the processing of this script, you will now be redirected back, please try again.");</script>';
echo '<script>history.back(1);</script>';

exit;

}
}

?>

 

Link to comment
Share on other sites

The first file you posted, the one with the header(). Is that your member.php file??

 

Secondly, I see this:

 

while($row = mysql_fetch_array($query))
{ 

if ( $_POST['new'] == $_POST['confirm'] )
[b]{}[/b]else{

 

Are you purposely trying to do an else statement right away? If so, why not do != instead of ==?

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.