Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.