bran407 Posted November 23, 2007 Share Posted November 23, 2007 <?php session_start(); ?> <html> <head> <title> Login Test With Mysql</title> <Form action='index.php'?==login==yes' method=POST> Username <input type=text name='user'><br /> Password <input type=password name='pass'><br /> <input type=submit value='Login'> </form> <?php $user=$_POST['user']; $Pass=$_POST['pass']; $login=$_Get['login']; if ($login=='yes') { $con = mysql_connect("localhost","root","yournewpassword"); } else { echo "Connected to database please login"; } mysql_select_db('login'); $sql = "SELECT * FROM `users` WHERE `username`='$username' AND `password`='$password'"; $result = mysql_query($sql) or die(mysql_error()); mysql_close($con); if ($result=1) {echo "login failure!"; } else { echo "login success!"; } ?> </body> </html> and i think thats wrong but also i dunno how to test it mysql i tried CREATE TABLE `users` ( `user_id` int(4) NOT NULL auto_increment, `username` varchar(65) NOT NULL default '', `password` varchar(65) NOT NULL default '', PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; but i oculdnt figure out how to fill out a username/pass feild thanks so much for the help if u can guys!!!! Link to comment https://forums.phpfreaks.com/topic/78604-need-help-with-login/ Share on other sites More sharing options...
revraz Posted November 23, 2007 Share Posted November 23, 2007 If you are copying this from a book, recheck this line, it's wrong <Form action='index.php'?==login==yes' method=POST> Link to comment https://forums.phpfreaks.com/topic/78604-need-help-with-login/#findComment-397725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.