Me1337 Posted June 30, 2012 Share Posted June 30, 2012 Hello, I'm trying to get an html textbox assigned to a php variable so I can put this on my panel. Can you please revise and edit this code? <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("PenguinWorld", $con); mysql_query("UPDATE pw_users SET Nickname='nick' WHERE Username='username'"); mysql_close($con); ?> <html> <form name="input" action="changed.php" method="get"> Username:<INPUT TYPE = "Text" VALUE ="username" NAME = "username"><br> New Nick: <INPUT TYPE = "Text" VALUE ="nick" NAME = "nick"><br> <input type="submit" value="Submit" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/265021-please-help-edit-this-code-assign-an-html-textbox-to-a-php-variable/ Share on other sites More sharing options...
requinix Posted June 30, 2012 Share Posted June 30, 2012 The hard part is mysql_query("UPDATE pw_users SET Nickname='" . mysql_real_escape_string(???) . "' WHERE Username='" . mysql_real_escape_string(???) . "'"); The rest you can find with some creative Googling. Quote Link to comment https://forums.phpfreaks.com/topic/265021-please-help-edit-this-code-assign-an-html-textbox-to-a-php-variable/#findComment-1358075 Share on other sites More sharing options...
Me1337 Posted June 30, 2012 Author Share Posted June 30, 2012 The hard part is mysql_query("UPDATE pw_users SET Nickname='" . mysql_real_escape_string(???) . "' WHERE Username='" . mysql_real_escape_string(???) . "'"); The rest you can find with some creative Googling. Sorry, I'm not that familiar with PHP, I just started a week ago. I don't understand how that code you pasted would help. Quote Link to comment https://forums.phpfreaks.com/topic/265021-please-help-edit-this-code-assign-an-html-textbox-to-a-php-variable/#findComment-1358082 Share on other sites More sharing options...
requinix Posted June 30, 2012 Share Posted June 30, 2012 Then you best start learning, eh? Quote Link to comment https://forums.phpfreaks.com/topic/265021-please-help-edit-this-code-assign-an-html-textbox-to-a-php-variable/#findComment-1358095 Share on other sites More sharing options...
Genesis730 Posted June 30, 2012 Share Posted June 30, 2012 Me1337, mysql_real_escape_string or MRES is an important part of handling user input as far as security. You ALWAYS want to sanitize (make sure input is what you expect it to be and ONLY what you expect, nothing that might cause problems) user input cause you never know what might be sent. Quote Link to comment https://forums.phpfreaks.com/topic/265021-please-help-edit-this-code-assign-an-html-textbox-to-a-php-variable/#findComment-1358096 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.