3dhomejoe Posted June 30, 2008 Share Posted June 30, 2008 Hello, I have just found out at how great php is but im stuck at a part right now. Im trying to take text from a text box and add it to mysql when i click send but Ive been all over google and other forums, and no one has been able to help me. I would like it to be as basic as it can be, I have no scripts for that part right now. Thanks 3dhomejoe Quote Link to comment https://forums.phpfreaks.com/topic/112527-taking-text-from-a-box-to-mysql/ Share on other sites More sharing options...
Lamez Posted June 30, 2008 Share Posted June 30, 2008 First you need to connect to the database, do you know how to do that? Then you need a action script here is a good example (I wrote this, but it has been a while since I have done this) $data = $_POST['textfield']; mysql_query("INSERT INTO table VALUES ('$data')"); Quote Link to comment https://forums.phpfreaks.com/topic/112527-taking-text-from-a-box-to-mysql/#findComment-577802 Share on other sites More sharing options...
aeonsky Posted June 30, 2008 Share Posted June 30, 2008 To connect to MYSQL: function connect_mysql() { $mysql_host = 'localhost'; $mysql_username = 'INPUT_YOUR'; $mysql_password = 'INPUT_YOUR'; $mysql_db = 'INPUT_YOUR'; $conn = mysql_connect($mysql_host, $mysql_username, $mysql_password); if (!$conn) {echo 'Could not connect: ' . mysql_error(); die;}; mysql_select_db('$mysql_db') or die(mysql_error()); } Quote Link to comment https://forums.phpfreaks.com/topic/112527-taking-text-from-a-box-to-mysql/#findComment-577804 Share on other sites More sharing options...
3dhomejoe Posted June 30, 2008 Author Share Posted June 30, 2008 thanks, that worked Quote Link to comment https://forums.phpfreaks.com/topic/112527-taking-text-from-a-box-to-mysql/#findComment-577805 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.