notepad |
notepad |
Oct 24 2009, 12:39 AM
Post
#1
|
|
![]() Senior Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Official Designer Posts: 5,880 Joined: Nov 2007 Member No: 593,382 |
im wanting to make an online notepad for personal use. ive got a server. it could be like the one cb uses or this.
http://jumk.de/notepad/ i use that all the time but it sucks. haha. i figured the best way to do this would be with a database as opposed to cookies or something so that way you can always access it from any pc. how would i go about this? i only started learning database stuff recently. fanks. its also just for the learning experience. |
|
|
|
![]() |
Oct 24 2009, 01:02 AM
Post
#2
|
|
|
Senior Member ![]() ![]() ![]() ![]() ![]() ![]() Group: Member Posts: 1,237 Joined: May 2008 Member No: 648,123 |
Do you know about logins, too? Assuming you do, something as simple as the example you put could be done with five (you could do it with four if you really wanted to) columns in a database:
CODE <?php // Connect to MySQL mysql_query("CREATE TABLE memo (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), user CHAR(15) NOT NULL, pass CHAR(32) NOT NULL, date DATETIME NOT NULL, last DATETIME NOT NULL, memo TEXT NOT NULL)"); ?> CODE <?php // Create a new user if(count($_POST) > 0) { $user = $_POST['user']; $pass = md5($_POST['pass']); if($user && $pass) mysql_query("INSERT INTO memo ('', '$user', '$pass', NOW(), '', '')"); } ?> CODE <?php // Insert a new memo if(count($_POST) > 0) { $id = $_COOKIE['user']; // When they login, set a cookie as their user ID $memo = $_POST['memo']; mysql_query("UPDATE memo SET last = NOW() WHERE id = $id"); // Update the last memo time mysql_query("UPDATE memo SET memo = '$memo' WHERE id = $id"); // Update the memo } ?> CODE <?php
// To read the memo $id = $_COOKIE['user']; $query = mysql_fetch_assoc(mysql_query("SELECT date, last, memo FROM memo WHERE id = $id")); $date = $query['date']; $last = $query['last']; $memo = $query['memo']; ?> |
|
|
|
jcp notepad Oct 24 2009, 12:39 AM
JonHMChan I don't think this should be too hard if you k... Oct 24 2009, 12:46 AM
jcp ya i watched those. im also going through this.
ht... Oct 24 2009, 12:56 AM
jcp wow. i understand most of that code but i dont rea... Oct 24 2009, 01:07 AM
fixtatik Haha, it could have been a challenge for you if yo... Oct 24 2009, 02:19 AM
jcp ok so basically each time a user signs up it creat... Oct 24 2009, 09:27 AM
fixtatik Yup, that's the script to insert new users. It... Oct 24 2009, 11:42 AM
jcp so how does the file layout work? I have never don... Oct 27 2009, 01:46 PM
JonHMChan When you're running MySQL to create a table, y... Oct 30 2009, 01:03 PM
fixtatik If you're running it as-is, you'll have pr... Oct 30 2009, 02:38 PM
jcp so could you just give me like step by step instru... Nov 17 2009, 02:16 PM
fixtatik Do it for you, or explain a part better? What do y... Nov 17 2009, 08:00 PM
jcp I mean, what order do I make the files and which c... Nov 17 2009, 09:02 PM
fixtatik File order doesn't matter, because you're ... Nov 18 2009, 12:21 PM![]() ![]() |