/ Published in: PHP
Expand |
Embed | Plain Text
/*#### master.php ####*/ if(isset($userName) and isset($passWord)) { if(($userName==$user) and ($passWord==$pass)) { ?> <form method='post' action='blog_post.php'> Subject : <input name='subject' type='text' /><br /> Contents :<br /> <textarea name='contents' rows='20' cols='100'> </textarea> <br /> <button class="textArea" type='submit'>Post</button> </form></center> <?php } else { ?><font color="red">*User name or passwrd is not mach as the database. <br /> Please try again </font> <form method='post' action='master.php'> User Name : <input name='user' type='text' /><br /> Pass World : <input name='passwd' type='text' /><br /> <button class="textArea" type='submit'>Login</button> </form> <?php } } else { ?> <form method='post' action='master.php'> User Name : <input name='user' type='text' /><br /> Pass World : <input name='passwd' type='text' /><br /> <button class="textArea" type='submit'>Login</button> </form> <?php } ?> /*####### blog_post.php #######*/ <?php $query="INSERT INTO rksb_weblog(title,article,posterID,isMain,branch) VALUES('$subject','$article','$posterID', '$isMain', '$branch')"; ?> /*###### blog.php ######*/ mysql_select_db($database); function select ($page, $perpage) { $query = "SELECT id,". " title,". " article,". " posterID,". " isMain,". " branch,". " DATE_FORMAT(postDate, '%r %d-%m-%Y') as postDate". " FROM rksb_weblog". " ORDER BY postDate". " LIMIT $page, $perpage"; return mysql_query($query); } if (isset($_GET['page'])) { $page = $_GET['page']; $counter=+$page; } else { $page = 0; $counter=0; } $page *= $perpage; $result = select($page, $perpage); while($row = mysql_fetch_assoc($result)) { echo "<h3>".$row['title']." ".$row['postDate']."</h3><br />". "<p>".$row['article'] ."</p><br />". "<br />". "<a href='./blog.php?id=comment&comID=".$counter."'>". "COMMENT(0)</a>"; }/* if(!$row) { echo "<h3>There is no article ....</h3><br />". "<p>I am really sorry tho...<br />". "I haven't posted any blog article <br />". "Please try to come here any other day ... <br />". "Thank you for your visiting today !! </p><br />"; }*/ ?> /*##### data base #####*/ if (!$con) { die('Could not connect: ' . mysql_error()); } else { print "Connected to server "; } // create data mysql_select_db("mysql_db", $con); //when you want delete the table, comment out mysql_query("DROP TABLE rksb_weblog"); // when you wanna crerate table, comment out $query = "CREATE TABLE rksb_weblog". " (id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,". " title VARCHAR(100) NOT NULL,". " article LONGTEXT NOT NULL,". " posterID INT NOT NULL,". " isMain TINYINT NOT NULL,". " branch INT NOT NULL,". " postDate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE". " CURRENT_TIMESTAMP)"; mysql_query($query); if(!$query) { print "table was not created ".mysql_error(); } else { print "table has created "; } mysql_query($sql,$con);
You need to login to post a comment.
