GiantsFan23
Guest
Wrote this for a guy on Hackforums, thought I'd share it here as well. Let me know of any bugs / issues. Planning on adding some security to it with a login system if I get the time and people want it.
Here is the table, and the coding. All you have to do is set config.php to be connected to your database.
Then find the little SQL window, and run the following query:
Here is the main page, notepad.php:
And the action, update.php is below. On update.php, update the "$update" query with your database name where it says `database_name`.`notepad`. Here is the code:
Here is the table, and the coding. All you have to do is set config.php to be connected to your database.
Code:
CREATE TABLE `notepad` (
`id` int(1) NOT NULL,
`text` varchar(500) NOT NULL,
`time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Then find the little SQL window, and run the following query:
Code:
INSERT INTO `notepad` (`id`, `text`, `time`) VALUES
(1, 'This is your personal notepad! 500 character limit!', '2010-09-12 12:02:12')
Here is the main page, notepad.php:
PHP:
<?php include('config.php');
$grabinfo = mysql_query("SELECT * FROM notepad WHERE id = '1'");
while($fetch = mysql_fetch_array($grabinfo))
{
$text = $fetch['text'];
$time = $fetch['time'];
}
?>
<style type="text/css">
#notepad { text-align: center; }
</style>
<div id="notepad">
<form action="update.php" method="post">
<textarea name="text" id="text" rows="10" cols="30"><?php echo $text; ?></textarea>
<input type="submit" name="submit" id="submit" value="Submit">
</form>
</div>
And the action, update.php is below. On update.php, update the "$update" query with your database name where it says `database_name`.`notepad`. Here is the code:
PHP:
<?php include('config.php');
if(isset($_POST['submit'];))
{
$text = mysql_real_escape_string($_POST['text'];
$update = mysql_query("UPDATE `database_name`.`notepad` SET text = '".$text."'");
if($update)
{
echo "Notepad content updated!";
}
else
{
echo "Notepad content unsuccessfully updated!";
}
?>