A Note Pad in php

Page 1 of 1

0 Replies - 94083 Views - Last Post: 31 July 2009 - 07:22 AM

#1 Denis1  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 32
  • View blog
  • Posts: 104
  • Joined: 29-July 09

A Note Pad in php

Posted 31 July 2009 - 07:22 AM

This tutorial uses the deprecated mysql extension (as of PHP 5.5.0) which should not be used for writing new code as it will be removed in the future. The mysqli (MySQL Improved) or PDO extension should be used instead.

Nevertheless, it has been decided to keep this tutorial available until such time as it has been either updated or re-written. In the meantime, if you wish to take the tutorial, then it is recommended that you change the mysql-extension code to use mysqli or PDO. (If you do this successfully then perhaps you might consider submitting a revised tutorial, contributing to dream.in.code and earning some Kudos!)




100TH PHP TUTORIAL
I am going to show you how to create a notepad using php.
before we start i need you to check you connection to mysql from php is correct and every thing is working fine.

Step one // adding database fields in mysql.

-- 
-- Table structure for table `notepad`
-- 

CREATE TABLE `notepad` (
 `id` int(11) NOT NULL auto_increment,
 `note_pad` text NOT NULL,
  PRIMARY KEY  (id)
) ENGINE=MyISAM AUTO_INCREMENT=3023 DEFAULT CHARSET=latin1;


After that make a page in php call notepad.php

Step two// style CSS insert it in the head part of the page

<style type="text/css">
<!--
body,td,th {
	color: #FFFFFF;

}
.entryfield {
	background-color:#3A281C;
	border:1px solid #000000;
	font-size: 10px;
	font-family: verdana;
	width: 98%;
	color: #FFFFFF;
}

.button {
	width: 100px;
	margin: 2px;
	background-color: #5A0D07;
	color: #999999;
	cursor: pointer;
	border: 1px solid #000000;
	font-size: 10px;
	font-family: verdana;
	right: right;
}
-->
</style>


Step three // the php code
<?php
if(isset($_POST['Write'])){

$result = mysql_query("UPDATE login SET note_pad='".mysql_real_escape_string($_POST['note_pad'])."' WHERE id='" .mysql_real_escape_string($_SESSION['user_id']). "'") 
or die(mysql_error());

echo "Your notepad has been updated.";

$note_pad = $_POST['note_pad'];

}// update quote.
?>


Last Step // making the text box to write your message insert this in the body part of the page

<form method="post">
<table width="500" border="0" cellpadding="0" cellspacing="2" class="table">
  <tr>
	<td align="left" class="head">Notepad:</td>
  </tr>
  <tr>
	<td align="center" class="cell"><textarea name="note_pad" rows="30" class="entryfield" id="note_pad" style='width: 95%;'><?php echo htmlspecialchars(stripslashes($note_pad)); ?></textarea></td>
  </tr>
  <tr>
	<td align="right" class="submit"><input name="Write" type="submit" class="button" id="Write" value="Write." align="right" onfocus="if(this.blur)this.blur()" /></td>
  </tr>
</table>

</form>


there you go Note Pad where you can write your messages and update and save them on the database. think of it as a diary
Hope you like it enjoy.

This post has been edited by andrewsw: 30 January 2015 - 12:53 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1