Jump to content

taking text from a box to mysql


3dhomejoe

Recommended Posts

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

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')");

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());
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.