Log In · Register

 
notepad
Maccabee
post 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.
 
 
Start new topic
Replies
fixtatik
post Oct 24 2009, 11:42 AM
Post #2


Senior Member
******

Group: Member
Posts: 1,237
Joined: May 2008
Member No: 648,123



Yup, that's the script to insert new users. It just checks if the submit button is pushed, then it runs through a couple variables. It's extremely basic, so there's no security protection; something like that is very easy to abuse.

As for the form, something like this works fine:
CODE
<form action="action.php" method="post">
<input name="user" maxlength="15" />
<input name="pass" maxlength="16" />
<input type="submit" />
</form>

The file "action.php" contains the PHP code to insert the user into the database. What it's doing is counting the values in the $_POST array, and if that number is larger than 0 (i.e., the submit button was pushed), then it should insert the data. You could also do it like this:
CODE
<?php
if($_POST['user'] && $_POST['pass']) mysql_query("INSERT INTO memo VALUES ('', '{$_POST['user']}', '" . md5($_POST['pass']) . "', NOW(), '', '')");
?>

That checks if the "user" and "pass" fields are both set, and if they are, insert the data.

As for the query itself (notice the "VALUES" -- forgot that last time):
"INSERT INTO memo VALUES ('', '$user', '$pass', NOW(), '', '')"

You can also do it this way:
"INSERT INTO memo (user, pass, date) VALUES ('$user', '$pass', NOW())"

When you use blank quotes (''), nothing is inserted for that column (or in the case of auto incrementing, it'll insert the next number).

I'd suggest reading through the PHP manual on MySQL functions to get a better understanding of what you can do: http://php.net/manual/en/book.mysql.php
 

Posts in this topic


Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: