Gruzin Posted July 26, 2006 Share Posted July 26, 2006 Hi, I want the username and passowrd to be inputed in the database, but I've got a little problem:The username is not saved in the database, I don't undestand why. But Password is saved correctly. any ideas how can I fix that? Thank you.here is the code:<?php$con = mysql_connect("localhost","3d","password"); //connect to the sql database if(!$con) { die('Couldn"t connect'.mysql_error());}mysql_select_db("3d",$con); $insert = "INSERT INTO password(user, pass)VALUES('$_POST[$user]','$_POST[pass]')"; if(!mysql_query($insert,$con)) { die('Error'.mysql_error());}echo "Welcome George, your username and password is saved in Database";mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/15664-mysql-problem/ Share on other sites More sharing options...
redarrow Posted July 26, 2006 Share Posted July 26, 2006 $useruserok Quote Link to comment https://forums.phpfreaks.com/topic/15664-mysql-problem/#findComment-63858 Share on other sites More sharing options...
Gruzin Posted July 26, 2006 Author Share Posted July 26, 2006 Thanks man, I'am dead.....time to sleep now :P Quote Link to comment https://forums.phpfreaks.com/topic/15664-mysql-problem/#findComment-63860 Share on other sites More sharing options...
redarrow Posted July 26, 2006 Share Posted July 26, 2006 There you go mategood luck.[code]<?php//connect database.$con = mysql_connect("localhost","3d","password"); //connect to the sql database //post varables.$user=($_POST['user']);$pass=($_POST['pass']);//addslasshes to insert to database for database hekth lol....$user=addslashes($user);$pass=addslashes($pass);if(!$con) { die('Couldn"t connect'.mysql_error());}mysql_select_db("3d",$con);if($_POST['submit']) { $insert = "INSERT INTO password(user, pass)VALUES('$user','$pass')"; if(!mysql_query($insert,$con)) { die('Error'.mysql_error());}echo "Welcome $user, your username and $pass is saved in Database";//send user to the index page in stead of the above message ok.//header("location: index.php"); }mysql_close($con); ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15664-mysql-problem/#findComment-63861 Share on other sites More sharing options...
Gruzin Posted July 26, 2006 Author Share Posted July 26, 2006 Thanks, that's great:) Quote Link to comment https://forums.phpfreaks.com/topic/15664-mysql-problem/#findComment-63863 Share on other sites More sharing options...
redarrow Posted July 26, 2006 Share Posted July 26, 2006 Your more then welcome becouse you was nice,ill help you next time your on ok good luck mate. Quote Link to comment https://forums.phpfreaks.com/topic/15664-mysql-problem/#findComment-63867 Share on other sites More sharing options...
Gruzin Posted July 26, 2006 Author Share Posted July 26, 2006 thank u very much redarrow! I've already added u to my buddy list ;) Quote Link to comment https://forums.phpfreaks.com/topic/15664-mysql-problem/#findComment-63869 Share on other sites More sharing options...
redarrow Posted July 26, 2006 Share Posted July 26, 2006 ok mate pm me anytime ok. Quote Link to comment https://forums.phpfreaks.com/topic/15664-mysql-problem/#findComment-63870 Share on other sites More sharing options...
wildteen88 Posted July 26, 2006 Share Posted July 26, 2006 [quote author=redarrow link=topic=101891.msg403687#msg403687 date=1153904664]ok mate pm me anytime ok.[/quote]Kinda hard that when the PM system is disabled. Quote Link to comment https://forums.phpfreaks.com/topic/15664-mysql-problem/#findComment-64006 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.