View Single Post
  #9 (permalink)  
Old 09-03-08, 02:56 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
I was examining your code and I noticed besides the other problems that were corrected,
you seem to have a few minor problems in your table design.
I reorganized you table code so it is easier to read.
One thing you should keep in mind when creating tables, is to keep all your <td></td> on one line.
As some browsers (IE) will add spaces where you don't want them.

Also you are echoing each line of code causing the PHP interpreter to work much harder than it has to.

And you had three functions with the same name.

I made some suggested corrections.
PHP Code:

<?php

//This is, if you like the index page, it will be shown by default:
function indi()
{
 echo 
'<title>--::The Riflemans Arms - Events Entry Page::--</title>
       <p></p>
       <p align=center><font size=6><u>Riflemans Arms</u></font></p>
       <p></p>
       <p align=center><font size=4>Events Entry Page</font></p>
       <p></p>
       **In order to add an event you will need to have the password. If you forget
       the password, please contact the <a href=mailto:woody@scoobler.com>WebMaster</a>**
       <p></p>
       <form action=`events.php?function=process` method=POST>
        <table>
         <tr>
          <td colspan=2><p align=center><font size=4>Events Entry Page</font></p></td>
         </tr>
         <tr>
          <td>User Password: <i><a href=events.php?function=password>Help</a></i></td>
          <td><input type=password name=PASSWORD size=33></td>
         </tr>
         <tr>
          <td><b>Event Date: <i><a href=events.php?function=date>Help</a></i></b></td>
          <td><input type=text name=DATE size=33></td>
         </tr>
         <tr>
          <td><b>Event Name: <i><a href=events.php?function=name>Help</a></i></b></td>
          <td><input type=text name=NAME size=33></td>
         </tr>
         <tr>
          <td valign="top"><b>Event Description: <i><a href=events.php?function=description>Help</a></i></b></td>
          <td><textarea rows="6" name=DESCRIPTION cols="25"></textarea></td>
         </tr>
         <tr>
          <td><b>Event Expiry Date: <i><a href=events.php?function=expiry>Help</a></i></b></td>
          <td><input type=text name=EXPIRY size=33></td>
         </tr>
         <tr>
          <td><input type=SUBMIT value=SUBMIT></td>
          <td><input type=RESET value=`CLEAR FORM`></td>
         </tr>
        </table>
       </form>'
;
 }

//This is the page that processes the form results:
function one()
{
 echo 
'<title>--::The Riflemans Arms - Events Entry **SUCCESS** Page::--</title>
       <p></p>
       <p align=center><font size=6><u>Riflemans Arms</u></font></p>
       <p></p>'
;
 if(
$_POST["PASSWORD"] == 1989)
 {
  
$dbhost 'localhost'// access point to the database, normally "localhost"
  
$dbusername '****'// The database user name.
  
$dbpassword '********'// The database password.
  
$dbname 'riflemans'// The database's name.
  
$link mysql_connect($dbhost$dbusername$dbpasswd) or die("Could not connect: " mysql_error());
  print (
"Connected to $dbhost successfully.......");
  
$select mysql_select_db($dbname) or die("Could not connect to database: " mysql_error());
  print (
"Connected to '$_POST[dbname]' successfully.......");
  
$sql "INSERT INTO whatson VALUES ('".$_POST["DATE"]."','".$_POST["NAME"]."','".$_POST["DESCRIPTION"]."','".$_POST["EXPIRY"]."')";
  
$result mysql_query($sql);
  if (
$result)
  {
   echo(
"Successfully executed the database manipulation!");
   }
  else
  {
   echo(
"Error executing you request, please check and try again! <a href=events.php>Events Entry Page</a>");
   }
  }
 else
 {
  echo(
"Sorry you entered a incorrect or inactive password, please check and try again <a href=events.php>Events Entery Page</a>");
  }
 }

// This is the help page for the password field:
function two()
{
 echo 
'<title>--::The Riflemans Arms - Events **HELP** Page::--</title>
       <p></p>
       <p align=center><font size=6><u>Riflemans Arms</u></font></p>
       <p></p>
       <b>The Password field:</b>
       <br>This field has been added to stop unautherised personnel posting events.
       <br></br>
       <br>The password was issued by the <a href=mailto:woody@scoobler.com>WebMaster</a>.
       <br>If you have forgotten the password please contact the <a href=mailto:woody@scoobler.com>WebMaster</a> via email.'
;
 }
 
// This is the help page for the name field:
function three()
{
 echo 
'<title>--::The Riflemans Arms - Events **HELP** Page::--</title>
       <p></p>
       <p align=center><font size=6><u>Riflemans Arms</u></font></p>
       <p></p>
       <b>The Name field:</b>
       <br>This field is where you give the up and goming event a simple name. E.G. `Disco Night`'
;
 }
 
// This is the help page for the description field:
function four()
{
 echo 
'<title>--::The Riflemans Arms - Events **HELP** Page::--</title>
       <p></p>
       <p align=center><font size=6><u>Riflemans Arms</u></font></p>
       <p></p>
       <b>The Description field:</b>
       <br>This field is where you can write a detailed description of the up and coming event.
       <br>You can include HTML in your description to give the description more character.'
;
 }
 
// This is the help page for the expiry field:
function five()
{
 echo 
'<title>--::The Riflemans Arms - Events **HELP** Page::--</title>
       <p></p>
       <p align=center><font size=6><u>Riflemans Arms</u></font></p>
       <p></p>
       <b>The Expiry field:</b>
       <br>This field is where you give the up and goming event an EXPIRY date.
       <br>The Events page works by asking the database of any events who`s Expiry date is after that days date.
       Therefore set the expiry date to the last day you want the event to be shown up to. After the Expiry date
       the event will no longer appear on the Events Page.'
;
 }
 
// This is the help page for the date field:
function six()
{
 echo 
'<title>--::The Riflemans Arms - Events **HELP** Page::--</title>
       <p></p>
       <p align=center><font size=6><u>Riflemans Arms</u></font></p>
       <p></p>
       <b>The Date field:</b>
       <br>This field is where you give the up and goming event an DATE.
       <br>The Events page arranges the events by their up and coming date.
       Therefore set the date to the day when the event will occur.'
;
 }
 
// This is the switch function which tells the page which section of code to display.
switch($function)
{
 case 
"process":
  
one();
  break;
 case 
"password":
  
two();
  break;
 case 
"name":
  
three();
  break;
 case 
"description":
  
four();
  break;
 case 
"expiry":
  
five();
  break;
 case 
"date":
  
six();
  break;
 default:
  
indi();
 }
?>
__________________
Jerry Broughton