Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Login Right But Says Its Wrong

    I have made this code but for some reason it doesnt login i dont understand why
    PHP Code:
    <?
    ob_start
    ();
    mysql_connect('localhost''xxx''xxx');
    mysql_select_db('xxx');
    if(
    $_POST['login']){
    if(!
    $_POST['username'] && !$_POST['password']){
    $log "Please Supply A Username And Password";
    }
    else{
    $user $_POST['username'];
    $pass $_POST['passwprd'];
    $query "SELECT username, password, status FROM users WHERE username='$user' AND password='$pass'";
    $fetch mysql_query($query)or die(mysql_error());
    $result mysql_fetch_array($fetch);
    if(
    $result){
    if(
    $result['status'] == 0){
    session_start();
    $_SESSION['user'] = $user;
    header('location: index.php?page=activate');
    }
    else{
    session_start();
    $_SESSION['user'] = $user;
    header('location: index.php?page=base');
    }
    }
    else{
    $log "Wrong Username or Password";

    }
    }
    ?>
    <html>
    <head>
    <title>Chaos Fights</title>
    <link rel="stylesheet" href="main.css" type="text/css" />
    </head>
    <body>
    <table width="80%" align="center" cellpading="0" cellspacing="0">
    <tr>
    <td align="center"><img src="images/logo.jpg" alt="Chaos Fights" /></td></tr></table>
    <table width="80%" align="center" cellpading="0" cellspacing="0">
    <? if($log){
    ?>
    <tr>
    <td class="login"><?= $log?></tr></tr>
    <?
    }else{}
    ?>
    <tr><form action="" method="post">
    <td width="16%" class="login">Username:</td>
    <td width="16%" class="login"><input name="username" id="username" type="text" /></td>
    <td width="16%" class="login">Password:</td>
    <td width="16%" class="login"><input name="password" id="password" type="password" /></td>
    <td width="16%" class="login"><input name="login" id="login" type="submit" value="LogIn" /></td></tr></form></table>
    <table width="80%" align="center" cellpading="0" cellspacing="0">
    <tr><td class="login"><a href="?page=signup">Sign Up</a> | <a href="?page=forgot">Forgot Pass?</a></td></tr></table>
    <?
    if(empty($_GET['page'])){
    ?>
    <table width="80%" align="center" cellpading="0" cellspacing="0">
    <tr>
    <td width="20%" class="race">Space Marines</td>
    <td width="20%" class="race">Dwarves</td>
    <td width="20%" class="race">Elves</td>
    <td width="20%" class="race">Demons</td></tr><tr>
    <td width="20%" align="center"><img src="images/sm.jpg" alt="Chaos Fights" /></td>
    <td width="20%" align="center"><img src="images/dw.jpg" alt="Chaos Fights" /></td>
    <td width="20%" align="center"><img src="images/ev.jpg" alt="Chaos Fights" /></td>
    <td width="20%" align="center"><img src="images/de.jpg" alt="Chaos Fights" /></td></tr><tr>
    <td width="20%" class="race">Gather your troops to fight the coming horde! </td>
    <td width="20%" class="race">Come to the aid of your allies and destroy your enemies! </td>
    <td width="20%" class="race">Harness your strength and fight for your people! </td>
    <td width="20%" class="race">Use your might to spread evil throughout the land!</td></tr><tr>
    <td width="20%" class="race">25% Income Bonus</td>
    <td width="20%" class="race">30% Defense Bonus </td>
    <td width="20%" class="race">35% Spy Bonus </td>
    <td width="20%" class="race">30% Attack Bonus </td></tr></table><br><br><br><br><br>
    <table width=80% cellspacing=0 cellpading=0 align="center">
    <tr>
    <td class="news">Updates</td></tr></table>
    <table width=80% cellspacing=0 cellpading=0 align="center">
    <tr>
    <td class="update">June 18th 2007:</td></tr><tr>
    <td class="update">Chaos Fights V2 Started</td></tr></table>
    <?
    }
    else{
    switch(
    $_GET['page']){
    case 
    "signup":
    require_once 
    "register.php";
    break;
    case 
    "activate":
    require_once 
    "activate.php";
    break;
    }
    }
    ?>
    <br><br><br>
    <table width=80% cellspacing=0 cellpading=0 align="center">
    <tr>
    <td class="copyright">&copy; Chaos Fights Owned And Ran By: <a href="http://ewnetwork.info/" target="_blank">EW Network</a></td></tr></table>

    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    At first glance:

    1.
    PHP Code:
    if(!$_POST['username'] && !$_POST['password']) 
    This condition will only be true if no username AND no password has been set. I think you mean:
    PHP Code:
    if(!$_POST['username'] || !$_POST['password']) 
    1.
    Typo here:
    PHP Code:
    $pass $_POST['passwprd']; 

  • #3
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts
    yeah thats the only two things I noticed which were wrong. Fix those two things PappaJohn pointed out and it should all work smoothly.

  • #4
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    Thanks Alot It Worked thanks again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •