Page 1 of 1
php blogging application
Posted: Wed Aug 01, 2007 9:54 am
by carsky
hi everyone..guys need help on how to start coding a basic blog application..i intended to create a blogging application for my server-side..this will allow the admin to post announcement and other bulletins..maybe you could help me out with this..i tried downloading some but i guess dont know how to make it work..i would appreciate all the help that you can give me..im online right now at yahoo messenger.. this is my id tidi_fer007@yahoo.com..thanks in advance.
Posted: Wed Aug 01, 2007 10:37 am
by iknownothing
Heres something very basic, just to give you an idea, keep in mind the following code should be made safer.
Code: Select all
// admin_announcement.html
// Form which requires Admin to fill out
<form method="post" name="admin_notes" action="do_blogging.php">
<input type="text" name="admin_blog_title" />
<textarea name="admin_blog" rows="4" cols="20"></textarea>
<input type="submit" name="submitbutton" value="Submit" />
</form>
Code: Select all
// do_blogging.php
<?php
require("database_details.php"); // Connect to Database
if (isset($_POST['admin_blog'])) { // Check that form has been filled out
$admin_blog_title = $_POST['admin_blog_title']; // Getting Posted Form Entries
$admin_blog = $_POST['admin_blog'];
// Inserting into the Database
$insert_blog = mysql_query("INSERT INTO admin_blog (blog_title, blog_contents)
VALUES ('$admin_blog_title', '$admin_blog')");
// Checking for Inserting Errors
if (!mysql_query($insert_blog))
{
die('Error: ' . mysql_error());
}
echo "Announcement Added";
}
?>
Code: Select all
// view_admin_blog.php
<?php
require("database_details.php"); // Connect to Database
$result = mysql_query("SELECT * FROM admin_blog"); // Pull Data from Database
// Getting and display the entries (can be formatted better for appearance)
while($row = mysql_fetch_array($result))
{
echo $row['blog_title'];
echo "<br />";
echo $row['blog_contents'];
echo "<br />";
}
?>
Posted: Wed Aug 01, 2007 10:39 am
by purefan
A Blog application is actually fairly easy, you need to have a database, I prefer Mysql to work with php so heres a suggestion.
You need to have an html end for the form that will use the php script you are writing, this form should have a textarea field.
in the php script you want to connect to a database and insert the post there.
This is really basic insight (not talking about security and such) but you need to learn how to crawl before you walk, heres is a good link you may want to look at:
http://php-mysql-tutorial.com
Hope it helps