prcollin Posted May 27, 2008 Share Posted May 27, 2008 I have the following code as my login.php <?php $host="localhost"; $user="xxxxx_xxxxllin"; $passwd="xxxxxxx17"; $database="fxxx_Usxxs"; $con = mysql_connect("$host", "$user", "$passwd", "$database"); mysql_select_db("fixxxxx_xxxx", $con); $sql="insert into newuser (user_name, user_pass, full_name, user_email, confirm_email, alt_email, user_city) Values ('$_post[user_name]','$_post[user_pass]','$_post[full_name]','$_post[user_email]','$_post[confirm_memail]','$_post[alt_email]','$_post[user_city]"; echo "1 record added"; mysql_close($con) ?> And my html code is this <html> <body> <form action="login.php" method="post"> Username: <input type="text" name="username"> Password: <input type="password" name="password"> Full Name: <input type="text" name="name"> E-Mail : <input type="text" name="useremail"> Confirm E-mail: <input type="text" name="confirmemail"> Alt Email: <input type="text" name="altemail"> City: <input type="text" name="city"> <input type="submit" /> They are two separate files. I know there is no security or anything I am just trying to get stuff to post to the db cause I am new to MySQL. If you could help me find out what I did wrong or suggest a better way that would be great. PHP 5 and MySQL 4.1.22 Im not getting any connect errors when i click submit but the info isnt posting to the db. Link to comment https://forums.phpfreaks.com/topic/107484-help/ Share on other sites More sharing options...
BlueSkyIS Posted May 27, 2008 Share Posted May 27, 2008 you build the SQL, but you never execute it: mysql_query($sql) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/107484-help/#findComment-550913 Share on other sites More sharing options...
stuffradio Posted May 27, 2008 Share Posted May 27, 2008 ('$_post[user_name]','$_post[user_pass]','$_post[full_name]','$_post[user_email]','$_post[confirm_memail]','$_post[alt_email]','$_post[user_city]"; That is very dangerous. You need to sanitize the input first! Link to comment https://forums.phpfreaks.com/topic/107484-help/#findComment-550920 Share on other sites More sharing options...
prcollin Posted May 27, 2008 Author Share Posted May 27, 2008 ('$_post[user_name]','$_post[user_pass]','$_post[full_name]','$_post[user_email]','$_post[confirm_memail]','$_post[alt_email]','$_post[user_city]"; That is very dangerous. You need to sanitize the input first! i know i am just trying to get the connection to work Link to comment https://forums.phpfreaks.com/topic/107484-help/#findComment-550927 Share on other sites More sharing options...
prcollin Posted May 27, 2008 Author Share Posted May 27, 2008 Im getting the error, "query was empty" what the H**l does that mean? Link to comment https://forums.phpfreaks.com/topic/107484-help/#findComment-550928 Share on other sites More sharing options...
revraz Posted May 27, 2008 Share Posted May 27, 2008 echo $sql and find out. Link to comment https://forums.phpfreaks.com/topic/107484-help/#findComment-550937 Share on other sites More sharing options...
prcollin Posted May 27, 2008 Author Share Posted May 27, 2008 echo $sql and find out. im new to this, could you elaborate a little more. where do i throw that statement or could someone fix my previous code so that it will work? Link to comment https://forums.phpfreaks.com/topic/107484-help/#findComment-551004 Share on other sites More sharing options...
prcollin Posted May 27, 2008 Author Share Posted May 27, 2008 echo $sql and find out. im new to this, could you elaborate a little more. where do i throw that statement or could someone fix my previous code so that it will work? bump Link to comment https://forums.phpfreaks.com/topic/107484-help/#findComment-551046 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.