Forum is shutting down, join us on Discord.

- No new threads can be created
- Shoutbox has been disabled
- All chat/support/market will be on Discord
- if you have a special status on forum (ie: staff, legendary user, etc), then PM Phoenix on forum with your Discord name to reclaim your status on Discord
See you all on Discord!


  
Go Back   Twilight MU Online Forum > Community > Programming Section

Programming Section All programming related stuff goes here.


Welcome to the Twilight MU Online Forum forums.

You are currently viewing our boards as a guest which gives you limited access. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

After registering you will receive an email with a confirmation link that you will need to click in order to activate your forum account.

NOTE: It's recommanded that you use on forum a different username and password than the game username and password.

If you have any problems with the registration process or your account login, please contact contact us.

 
 
Thread Tools Display Modes

Login scipt MySQL problem
Old 02-01-2009   #1
albsky
I'm speshul x_X

 
albsky's Avatar
 
InGame Character:
My Mood:
albsky is offline
Points: 9,407, Level: 41
Points: 9,407, Level: 41 Points: 9,407, Level: 41 Points: 9,407, Level: 41
Level up: 80%, 93 Points needed
Level up: 80% Level up: 80% Level up: 80%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Rank: Platinum Member
Join Date: Jun 2008
Rep: albsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud of
Rep Power: 221
Casino Cash: 5538
Default Login scipt MySQL problem

Hey guys, I've coded a register script which works fine, and it goes to the table ´users´ with the following settings:
-ID
-Username
-Password
-Email
-Screenname
-IP

Ok, but my login script doesn't work, does someone know how?
Here is my login script:

Login2.php
Code:
<form id="form1" name="form1" method="post" action="login3.php">
  <p align="left" class="tdglobal"><span class="b01">User Control Panel</span></p>
  <table width="200" border="0" align="left" class="liteoption">
    <tr>
      <td width="97" class="left"><div align="left"><b>Username:</b></div></td>
      <td width="93" class="left"><input name="user" type="text" class="liteoption" id="user" size="15" maxlength="15" /></td>
    </tr>
    <tr>
      <td class="center"><div align="center"><b>Password:</b></div></td>
      <td class="center"><input name="pass" type="password" class="liteoption" id="pass" size="15" maxlength="15" /></td>
    </tr>
  </table>
  <br></br><br><p align="left" class="tdglobal"><span class="center">
    <input name="submit" type="submit" class="liteoption" id="submit" value="Log In" size="15" maxlength="15" />
  </span></p>
</form>
<p align="center" class="tdglobal">
Login3.php:
Code:
  <?php
if(isset($_POST['submit'])) {
$username = $_POST['user'];
$password = md5($_POST['pass']);

$con = mysql_connect("localhost","root","");
mysql_select_db("albsky", $con);

$result1 = "SELECT * FROM users WHERE username='$username' and password='$password'";
$query = mysql_query($result1);

$count = mysql_num_rows($query);


if($count == 1){

session_register("User_Name");
session_register("User_Pass");
$_SESSION['account'] = $_POST['user']; 
echo('Logged in.... Click <a href=?op=user><strong>here</strong></a>');
}
else {
echo "<strong>Try Again</strong>";
}
}
?>
  <br />
</p>
what should I change to let it work?
It connects to database but it can't find my user details
Ty in advance
__________________
-----

 

Old 03-01-2009   #2
albsky
I'm speshul x_X

 
albsky's Avatar
 
InGame Character:
My Mood:
albsky is offline
Points: 9,407, Level: 41
Points: 9,407, Level: 41 Points: 9,407, Level: 41 Points: 9,407, Level: 41
Level up: 80%, 93 Points needed
Level up: 80% Level up: 80% Level up: 80%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Rank: Platinum Member
Join Date: Jun 2008
Rep: albsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud of
Rep Power: 221
Casino Cash: 5538
Default

no one?
__________________
-----

 

Old 04-01-2009   #3
Jackel
Legend

 
InGame Character:
My Mood:
Jackel is offline
Points: 5,149, Level: 30
Points: 5,149, Level: 30 Points: 5,149, Level: 30 Points: 5,149, Level: 30
Level up: 50%, 151 Points needed
Level up: 50% Level up: 50% Level up: 50%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Dec 2006
Location: Canada
Age: 38
Rep: Jackel has a spectacular aura aboutJackel has a spectacular aura aboutJackel has a spectacular aura about
Rep Power: 213
Casino Cash: 507
Default

Replace
Code:
if($count == 1){
With..
Code:
if($count > 0){
You're checking $count against 1, which may not be the result. SELECT is selecting every row with your set clause, and if you have more than one result, it's not going to be 1.

It also may be a good idea to sanitize your POST variables. User input can be manipulated, and can quickly result in comprimisation of your database.

There is a MySQL PHP function that is very ideal, and highly recommended that you use.

Code:
$username = mysql_real_escape_string($_POST['user']);
Do this before including them into a query.

Last edited by Jackel; 04-01-2009 at 06:30 AM..
 

Old 04-01-2009   #4
albsky
I'm speshul x_X

 
albsky's Avatar
 
InGame Character:
My Mood:
albsky is offline
Points: 9,407, Level: 41
Points: 9,407, Level: 41 Points: 9,407, Level: 41 Points: 9,407, Level: 41
Level up: 80%, 93 Points needed
Level up: 80% Level up: 80% Level up: 80%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Rank: Platinum Member
Join Date: Jun 2008
Rep: albsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud ofalbsky has much to be proud of
Rep Power: 221
Casino Cash: 5538
Default

K, I'll try it, and I'll keep you update, maybe you could help me out more :P
__________________
-----

 
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -5. The time now is 09:26 AM.



vBulletin skin developed by: eXtremepixels
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright ©2006 - 2019 Twilight MU. All Rights Reserved