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 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')"); 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()); } 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 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
Archived
This topic is now archived and is closed to further replies.