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

New Topic/Question
This topic is locked



MultiQuote

|