Php textbox dump on a database

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 :slight_smile:

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…


<?
$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

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…

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

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

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.

:slight_smile: