joshuaceo Posted December 4, 2008 Share Posted December 4, 2008 Hi I wanted to ask if anyone can help me. I am trying to input a MD5 encrypted password to mysql. Here are the 2 files: File 1. userinput.html <html> <body> <form action="insert.php" method="post"> Newsletters: <input type="text" name="newsletters" /><br><br> Updates: <input type="text" name="updates" /><br><br> First Name: <input type="text" name="fname" /><br><br> Last Name: <input type="text" name="lname" /><br><br> Login: <input type="text" name="login" /><br><br> Password: <input type="text" name="password" /><br><br> Company: <input type="text" name="company" /><br><br> Address: <input type="text" name="address1" /><br><br> Address2: <input type="text" name="address2" /><br><br> City: <input type="text" name="city" /><br><br> State: <input type="text" name="state" /><br><br> Province: <input type="text" name="province" /><br><br> Zip: <input type="text" name="zip" /><br><br> Country: <input type="text" name="country" /><br><br> Email: <input type="text" name="email" /><br><br> Email Mode: <input type="text" name="email_mode" /><br><br> Phone: <input type="text" name="phone" /><br><br> <input type="submit" /> </form> </body> </html> File 2 insert.php <?php $con = mysql_connect("localhost","crown_brownu","asdfasdf"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("crown_brownies", $con); $sql="INSERT INTO users (newsletters, updates, fname, lname, login, password, company, address1, address2, city, state, province, zip, country, email, email_mode, phone) VALUES ('$_POST[newsletters]','$_POST[updates]','$_POST[fname]','$_POST[lname]','$_POST[login]','$_POST[password]','$_POST[company]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[province]','$_POST[zip]','$_POST[country]','$_POST[email]','$_POST[email_mode]','$_POST[phone]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 user added"; mysql_close($con) ?> I am trying to make it so when I submit the form in userinput.html it sends a MD5 password to mysql. I really hope someone can help me fix this. it is very important :'( Quote Link to comment https://forums.phpfreaks.com/topic/135471-any-smart-php-nerds-i-need-help-inputting-a-md5-encrypted-password-to-mysql/ Share on other sites More sharing options...
zenag Posted December 4, 2008 Share Posted December 4, 2008 $password=md5($_POST[password]); $sql="INSERT INTO users (newsletters, updates, fname, lname, login, password, company, address1, address2, city, state, province, zip, country, email, email_mode, phone) VALUES ('$_POST[newsletters]','$_POST[updates]','$_POST[fname]','$_POST[lname]','$_POST[login]','$password','$_POST[company]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[province]','$_POST[zip]','$_POST[country]','$_POST[email]','$_POST[email_mode]','$_POST[phone]')"; Quote Link to comment https://forums.phpfreaks.com/topic/135471-any-smart-php-nerds-i-need-help-inputting-a-md5-encrypted-password-to-mysql/#findComment-705766 Share on other sites More sharing options...
joshuaceo Posted December 4, 2008 Author Share Posted December 4, 2008 Thanks soooo much zenag. This really helped me. by the way do u know how to make a html selection form do the following: i choose usa in selection dropdown...and after this the state field appears below with usa states. I choose canada and a canada states selection dropdown box shows etc..? hope u can help Quote Link to comment https://forums.phpfreaks.com/topic/135471-any-smart-php-nerds-i-need-help-inputting-a-md5-encrypted-password-to-mysql/#findComment-705778 Share on other sites More sharing options...
zenag Posted December 4, 2008 Share Posted December 4, 2008 it can be done using javascript... see this sample code.... index.php <script type="text/javascript"> function pass(val) { window.location="index.php?value="+val; } </script> <select onChange="pass(this.value)"name="country"><option value="">select values</option><option value="0">0</option><option value="1">1</option></select> <? $values=$_GET["value"]; if(isset($values)) { echo $values; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135471-any-smart-php-nerds-i-need-help-inputting-a-md5-encrypted-password-to-mysql/#findComment-705782 Share on other sites More sharing options...
joshuaceo Posted December 4, 2008 Author Share Posted December 4, 2008 Thanks so much. Now adding to my first message. Is there a way to make the information go to 2 separate tables (user_shipping and users)? But in the second table only (address1, address2, city, state, zipcode, country) get submitted. Is this possible and how can i do this? Also would I need to make 2 insert.php files? I hope you can help with this last question. Thanks soo much! Quote Link to comment https://forums.phpfreaks.com/topic/135471-any-smart-php-nerds-i-need-help-inputting-a-md5-encrypted-password-to-mysql/#findComment-706341 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.