NaN:NaN
NaN:NaN
--:-- / --:--
Newgrounds Background Image Theme

Someone gifted Gelert supporter status!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

MySQLi login problem

1,378 Views | 3 Replies
New Topic Respond to this Topic

MySQLi login problem Mar 8, 2009


I've been trying to create my login with MySQLi, but I'm having some problems. I could create the register fine with MySQLi, but this..Just isn't going well. I'm new to it, so, I'm just trying out.

The problem is that when I try and login, it just refreshes the page. I checked the source and the error script is there, but it doesn't actually do anything. I'm not sure why it's saying my password / username are wrong, though. I tried print_r with the username / password. Everything matched up to the database.

Code:

<?php include('connect.php'); /** Logging in. **/ $password = $mysql->real_escape_string($_POST['password']); $username = $mysql->real_escape_string($_POST['username']); if(isset($_POST['submit'])) { $query = $mysql->prepare('SELECT username, password FROM users WHERE username = ? AND password = ?'); $query->bind_param('ss', $username, $password); $query->execute(); $query->bind_result($col1, $col2); if($query->num_rows > 0) { $_SESSION['logged_in'] = $username; header('http://www.blindtosound.com/forum/'); } else { echo '<script type="text/javascript">alert(\'No account with that combination found.\');</script>'; } } // Logged in. if(isset($_SESSION['logged_in'])): echo 'Logged in as '.$_SESSION['logged_in']; else: ?> <br /> <form method="post" action="http://www.blindtosound.com/forum/index.php"> <input type="text" name="username" /> <input type="text" name="password" /> <input type="submit" name="submit" value="Log in" /> <input type="button" name="register" value="Register?" onclick="window.location.href='http://www.blindtosound.com/forum/register.php';" /> </form> <br /> <?php endif; ?>

Gaming rig: 4GB OCZ 800Mhz RAM, Intel Core 2 Duo @ 3.6GHz, ATI Radeon HD 4870 ( 1.8GB vRAM ), Asus P5Q Pro motherboard, 22-inch Acer widescreen ( 1680x1050 ) monitor

BBS Signature

Response to MySQLi login problem Mar 8, 2009


Anyone?


Gaming rig: 4GB OCZ 800Mhz RAM, Intel Core 2 Duo @ 3.6GHz, ATI Radeon HD 4870 ( 1.8GB vRAM ), Asus P5Q Pro motherboard, 22-inch Acer widescreen ( 1680x1050 ) monitor

BBS Signature

Response to MySQLi login problem Mar 9, 2009


Seems you are forgetting to fetch.


BBS Signature

Response to MySQLi login problem Mar 9, 2009


Why are you not using the code I gave you?