# Php textbox dump on a database

**URL:** <https://forum.kirupa.com/t/php-textbox-dump-on-a-database/21541>\
**Category:** Uncategorized\
**Created:** [May 22, 2003, 7:19pm UTC](https://forum.kirupa.com/t/php-textbox-dump-on-a-database/21541 "2003-05-22T19:19:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlk](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@mlk](https://forum.kirupa.com/u/mlk)\
**Post date:** [May 22, 2003, 7:19pm UTC](https://forum.kirupa.com/t/php-textbox-dump-on-a-database/21541/1 "2003-05-22T19:19:27Z")

</div>

ok here’s what im trying to do, my server has php and mysql enabled; i want a page with a password and textbox, where i can write anything (sort of a e-notebook), and be able to send that to an archive and view the whole thing later in an html page with a password… can anyone help me on the code, php/mysql handling ? (i have no idea how it reall works)  
thnx guys 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 23, 2003, 4:39am UTC](https://forum.kirupa.com/t/php-textbox-dump-on-a-database/21541/2 "2003-05-23T04:39:39Z")

</div>

You have no idea? None whatsoever? Ok, well first create a database. Lets say we name it **myDB** and we’ll add a user to it, say the user is **myName** and the password is **myPass** and I’m assuming that the host would be **localhost**

Now the database has a table that we’re going to call **notes** , and _notes_ has 2 fields: **text** and **id**. We’re going to make the field _id_ be auto-incrementing to keep track of how many entries you make, and also make it so that we can control how we print out the entries.

This can be done all with one file, so I will do it that way…

```php

<?
$submit = $_POST['submit'];
$text = $_POST['text'];
//If statement checks to see if you enter your data
if($submit)
{

//Create the variables to connect to database
$host = "localhost";
$user = "myName";
$pass = "myPass";
$db = "myDB";

//Connection to database
$linkID = mysql_connect($host, $user, $pass);
mysql_select_db($db, $linkID);

//Query to insert the data into the database
$query = "INSERT INTO notes(text) VALUES('$text')";
$resultID = mysql_query($query, $linkID);

//if statement to check if resultID is true
if($resultID)
{
      print "Data entered successfully.";
}
else
{
      print "There was an error. Jubba gave you faulty code. Kill him.";
}

//Closes the database.
mysql_close($linkID);

}

?>
<html>
<body>
<form action="<? echo $PHP_SELF ?>" method="POST">
<textarea cols="35" rows="35" name="text">Put your crap here</textarea>
<br />
<input type="submit" name="submit" value="CLICK IT!">
</form>

```

Thats how the main page should look. Kind of.

I’m not sure where you want the password thing to come in… let me know fi this helps and I’ll try to help some more

Cheers,  
Jubs

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 24, 2003, 1:48pm UTC](https://forum.kirupa.com/t/php-textbox-dump-on-a-database/21541/3 "2003-05-24T13:48:19Z")

</div>

great thnx - me is trying to learn PHP - i hope somefool in the matrix can put those little MiniDisc in my brain with ‘Php-knowledge’ on it…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 24, 2003, 3:05pm UTC](https://forum.kirupa.com/t/php-textbox-dump-on-a-database/21541/4 "2003-05-24T15:05:13Z")

</div>

If you are really trying to learn and you’re serious about it, then get these two books:

**PHP:** [http://www.amazon.com/exec/obidos/tg/detail/-/0764535617/qid=1053751242/sr=8-1/ref=sr\_8\_1/002-2551283-1162431?v=glance&s=books&n=507846](http://www.amazon.com/exec/obidos/tg/detail/-/0764535617/qid=1053751242/sr=8-1/ref=sr_8_1/002-2551283-1162431?v=glance&s=books&n=507846)

**mySQL:** [http://www.amazon.com/exec/obidos/tg/detail/-/0764516922/qid=1053751276/sr=1-2/ref=sr\_1\_2/002-2551283-1162431?v=glance&s=books](http://www.amazon.com/exec/obidos/tg/detail/-/0764516922/qid=1053751276/sr=1-2/ref=sr_1_2/002-2551283-1162431?v=glance&s=books)

They are priceless. They have helped me so much. All of my knowledge of PHP and mySQL manipulation pretty much began with that and in just a week or so I was create full control panels for websites. Together the price is about $50 but don’t whine about spending the money because they are worth every penny. **mdipicom** bought the PHP after I recommended it to him and he loved it. If you have 3/4 of a brain cell you will understand PHP when you get done with those books.

Actually the first one is all you really need because it actually explains the basics of php/mysql all in one, but the second book helps with more specific areas of the mysql.

🙂
