Login   Register  
PHP Classes
elePHPant
Icontem

File: admin/addNewsForm.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Andrew  >  News Script  >  admin/addNewsForm.php  >  Download  
File: admin/addNewsForm.php
Role: Application script
Content type: text/plain
Description: Add a News Item
Class: News Script
Manage and publish news stored in a MySQL database
Author: By
Last change:
Date: 6 years ago
Size: 1,221 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Add News</title>
</head>

<body>
<h1>Add News</h1>
<form method="post" action="<?php $_SERVER['PHP_SELF']?>">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td>Name</td>
    <td><input type="text" name="txtAuthor" /></td>
  </tr>
  <tr>
    <td>News</td>
    <td><textarea name="txtContent" cols="60" rows="5"></textarea></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" value="Submit" /></td>
  </tr>
</table>
</form>
</body>
</html>
<?php

if($_POST['Submit'])
{
    
    if(!empty(
$_POST['txtAuthor']) && !empty($_POST['txtContent']))
    {

        include (
'../NewsScript.php');

        
$news = new NewsScript();
        
        
/**
         * notice we don't deal with bad input here, 
         * the NewsScript object does this for us using our clean() function
         */
        
$news->addNews($_POST['txtAuthor'], $_POST['txtContent']);
    }
    else 
    {
        echo 
"Please complete the form.";
    }
}
?>