Revision: 40718
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 6, 2011 03:09 by AzNGTX2
Initial Code
<?php //mysql database connection $dbhost='Database Host'; $dbuser='Your Username'; $dbpass='Your Password'; $dbtable='Your Table Name'; mysql_connect("$dbhost", "$dbuser", "$dbpass") or die("Could not connect."); mysql_select_db("$dbtable") or die("Table could not be selected."); //Submit Form if(isset($_POST['submit'])) { $yourpost=$_POST['yourpost']; $blogid=$_POST['blogid']; if(strlen($yourpost)<1) { print "You did not enter a message."; //no message entered } elseif($blogid != '') { $qry = "SELECT * FROM kyproject_blog WHERE blogid='$blogid'"; $result = mysql_query($qry); if($result) { if(mysql_num_rows($result) > 0) { echo 'Blog ID is already in use.'; } @mysql_free_result($result); } else { die("Query failed"); } }else{ $displaytime=date("F j, Y, g:i A"); //SQL Queries $insertpost="INSERT INTO kyproject_blog(blogid, message, date) values('$blogid','$yourpost','$displaytime')"; mysql_query($insertpost) or die("Could not insert post"); //insert post print "Blog entry added. View it <a href='blog.php?id=$blogid'>here</a>."; } }else{ print "<fieldset> <form action='' method='post' id='ticketform'> <p><label>Blog ID(Identifier Name):</label> <input name='blogid' id='textarea' type='text' /></p> <p><label>Blog Entry:</label> <textarea cols='50' rows='11' name='yourpost' id='message' class='bbeditor'></textarea></p> <p><input name='submit' class='formbutton' value='Submit' type='submit' /></p> </form>"; } print "</td></tr></tbody></table> </fieldset>"; ?>
Initial URL
Initial Description
Initial Title
PHP Blog: Insert2.php
Initial Tags
Initial Language
PHP