Jump to content

Recommended Posts

when ever anyone tries to log into my game they get incorrect user/pass no matter the user if they are correct they still get it. I think it may be a small code problem.

 

THE LOGIN

<?php include("config.php"); session_start();  ?>

<?php
if (!$user || !$pass) {
include("head2.php"); 
print "Please fill out all fields.";
exit;
}
include("head2.php"); 
$logres = mysql_num_rows(mysql_query("select * from players where user='$user' and pass='$pass'"));
$stat = mysql_fetch_array(mysql_query("select * from players where user='$user' and pass='$pass'"));
if ($logres <= 0) {
;?>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
.style4 {font-size: 24px}
-->
</style>

<table width="700" border="0" align="center" style="border:3px solid #65460F;">
  <tr>
    <td bgcolor="65460F" style="border:3px solid #65460F;" border="0">Wrong Username/Password. <a href="http://www.hobotown.co.uk">Try Again?
      </a>
      <p align="center">
</p></table>
<?
exit;
} else {
session_register("user");
session_register("pass");
}
$ip = " $_SERVER[REMOTE_ADDR] ";
mysql_query("update players set ip='$ip' where id=$stat[id]");
?>
<div align="center">
  <table width="700" height="411" border="0" align="center" style="border:3px solid #65460F;">
  <tr>
    <td width="270" height="407" bgcolor="#000000" style="border:0px solid #65460F;" border="0"><div align="center"><img src="http://www.shadowsarcane.com/images/ganster3.jpg" alt="http://www.shadowsarcane.com/images/ganster3.jpg" height="405" style="cursor: -moz-zoom-out;" />
    </div>
    <td width="414" bgcolor="#65460F" style="border:3px solid #65460F;" border="0"><p align="center">So you return, <?php print"$stat[user]"; ?>? Maybe not so clever after all, last time you upset the wrong type of people. Now Paul runs the town with the help of his boys. This time to survive you will have to train hard and fight fast. Again you will have to prove your worth and try survive the streets.<br />  
        <br />
        Oh yeah, welcome back!<br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <a href="stats.php"><br />
        Enter HoboTown V2</a></p>
</table>
<br />
<div align="center"><a href="http://www.hobotown.co.uk/forums/index.php?showforum=3">Need help with this page?</a> // ©2007 DesignAnyone.Com </div>

 

INDEX LOGIN BOX

             <form method="post" action="login.php">
                              <table border="0" style="font-size: 10pt">
                                <tr>
                                  <td>Username:</td>
                                  <td><input type="text" name="user" size="12" style="font-family: Verdana; font-size: 10px; font-weight: bold; border-style: solid; border-width: 1; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1" id="inUserD" /></td>
                                </tr>
                                <tr>
                                  <td>Password:</td>
                                  <td><input type="password" name="pass" size="12" style="font-family: Verdana; font-size: 10px; font-weight: bold; border-style: solid; border-width: 1; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1" /></td>
                                </tr>
                                <tr>
                                  <td> </td>
                                  <td align="center"><input type="submit" value="Login" name="login" /></td>

 

then the header used for all pages after they log in.

 

<?php
function commas($input) {
$input = number_format($input,0,".",",");
return $input;
}

if (!session_is_registered("user") || !session_is_registered("pass")) {
print "<center><font color=silver>Your session is over you will need to log back in....<a href=index.php>CLICK HERE</a>.";
exit;
}
$stat = mysql_fetch_array(mysql_query("select * from players where user='$user' and pass='$pass'"));
if (empty ($stat[id])) {
print "Invalid login.";
exit;
}

 

 

any ideas no matter who logs in it still says incorrect user/pass..

 

website address avalible if needed.

 

Link to comment
https://forums.phpfreaks.com/topic/51689-incorrect-userpass/
Share on other sites

Where are $user and $pass being set?

 

You're also missing the beginning of your tag here:

 

<?
exit;
} else {
session_register("user");
session_register("pass");
}
$ip = " $_SERVER[REMOTE_ADDR] ";
mysql_query("update players set ip='$ip' where id=$stat[id]");
?>

 

Should be <?php there.

Link to comment
https://forums.phpfreaks.com/topic/51689-incorrect-userpass/#findComment-255856
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.