Ok im making a web site not only for a final project in school but also for my grandmother. My class is web scripting, So im not learning anything about php.. My problem is that on the guest book page which is "display.html" if i try to sumit a comment it opens up to download the "insert. php"!! Am i suppose to make the insert.php actually insert.html?? it kinda looks like a style sheet to me!! Any help would be greatly appricated.. Here is my code for the intire project...
index.html
CODE
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<title>
Madison Brotherhood
</title>
<link rel="stylesheet" href="theme.css" type="text/css" />
</head>
<body>
<div id="container">
<h1>
Madison Brotherhood
</h1>
<center><p>
About Us:
We Have been about us goes here!!!</p>
</center><br />
<table style="position:absolute; z-index:9 !important; left:0px; center: 0px;" border="10">
<tr><td>
Navigation
</td></tr>
<tr>
<td><a href="index.html"> Home</a> </td>
</tr>
<tr>
<td><a href="display.html"> News Letters</a></td>
</tr>
<tr>
<td><a href="member.html"> Member Info</a></td>
</tr>
</table>
<br/><br/><br/>
<br/><br/>
<br/><br/><br/>
<br/><br/>
<br /><br />
<br /><br />
<br />
<div id="footer">Copyright © 2009 Madison Brotherhood
<br />
</div>
<div id="tab">
<tr>
<td><a href="index.html"> Home</a> </td>
</tr>
<tr>
<td><a href="display.html"> News Letters</a></td>
</tr>
<tr>
<td><a href="member.html"> Member Info</a></td>
</tr>
</div>
</div>
</body>
</html>
display.html
CODE
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<title>
Madison Brotherhood
</title>
<link rel="stylesheet" href="theme.css" type="text/css" />
<style>
body
{
background: #ffffcc;
color: #000000;
font-family: verdana;
font-size: 12;
}
tr.head
{
background: #ccaa66;
font-family: verdana;
font-size: 14;
}
tr.main
{
font-family: verdana;
font-size: 12;
background: #ccaa66;
}
input.button
{
background: darkblue;
color: white;
letter-spacing: 1px;
width: 120;
}
</style>
<div id="container">
<h1>
Madison Brotherhood
</h1>
</div>
<h2>
<center>
Brothers and Sisters that care
</center>
</h2>
<p align = "center"> Come and join in on <strong>GRAND OPENING </strong> of O'Rendezvous with Hammer and Susan,<br /><br />
new owners on july 4, 2009 at 1pm after Brotherhood meeting. Ya'll come, Free fixins and Barbecue.<br /><br />
Crystal Miller will perform keraoke and Ventriloquist show. 1pm to 4pm july 11, 2009 at 4pm to 7pm <br /><br />
Jackie Wilmore and joyce Bridges are sponsoring <strong> FISH FRY </strong> <b> at O'Rendez for Adolph LePre.</b><br /><br />
Free food and door prizes. Crystal Miller entertaining from 4pm till 7pm.
</p><br /> <br />
<table align="center" border="0">
<tr><td>Happy Birthday July Babies; Terrell Harp-<br />
Greg Hopkinds-Jeff Ducan-Carolyn Neff-<br />
Pat Sullivan- Dan Frady_Brenda Nichols-<br />
Josh Bradley-Jean Scarbrough-Shadow-<br /> Lenora Corbett
<td>
Last meeting Becky Sexton accepted<br />
chairperson for Charity and John<br />
Bodily accepted for food and<br />
entertainment committee</td>
</table>
<br /><br /><br /><br /><br /><br />
<title>Guestbook</title>
</head>
<body>
<table style="position:absolute; z-index:9 !important; left:0px; center: 0px;" border="10">
<tr><td>
Navigation
</td></tr>
<tr>
<td><a href="index.html"> Home</a> </td>
</tr>
<tr>
<td><a href="display.html"> News Letters</a></td>
</tr>
<tr>
<td><a href="member.html"> Member Info</a></td>
</tr>
</table>
<center>
<i>
Welcome to Madison Brotherhood Guestbook!
<br />
If you would like to comment on the News Letters please do so here!
</i>
<form method="post" action="insert.php">
<table border="0">
<tr class="head">
<td align="center" colspan="2">Guestbook</td>
</tr>
<tr class="main">
<td width="75">Name</td>
<td width="175" align="right"><input type="textfield" size="53" name="txtName"></td>
</tr>
<tr class="main">
<td width="75">E-mail</td>
<td width="175" align="right"><input type="textfield" size="53" name="txtTitle"></td>
</tr>
<tr class="main" vAlign="top">
<td width="75">Message</td>
<td width="175" align="center"><textarea cols="40" rows="10" name="txtaMessage"></textarea></td>
</tr>
<tr class="head">
<td colspan="2" align="right"><input class="button" type="submit" value="Submit"></td>
</tr>
</table>
</form>
<? include "listguests.php" ?>
</center>
<br/><br/>
<br/><br/>
<br/><br/>
<br/>
<br/>
<div id="footer">Copyright © 2009 Madison Brotherhood
<br />
</div>
<div id="tab">
<tr>
<td><a href="index.html"> Home</a> </td>
</tr>
<tr>
<td><a href="display.html"> News Letters</a></td>
</tr>
<tr>
<td><a href="member.html"> Member Info</a></td>
</tr>
</div>
</body>
</html>
theme.css
CODE
body { background-color: #ffffcc;
color: #330000;
font-family: Verdana, Arial, sans-serif;
}
h1 { background-color: #ccaa66;
color: #000000;
line-height: 200%;
text-align: center;
}
#nav{ text-align: center;
}
#footer {background-color: #ccaa66;
font-size: .60em;
font-style: italic;
text-align: center;
}
#container {margin-left: auto;
margin-right: auto;
width:80%;
}
#tab {background-color: #33CCFF;
font-style: bangle;
text-align: center;
)
#image(background-image: url('logo.JPEG');
background-repeat: no-repeat;
background-attachment:fixed;
background-position: 50% 30%;
}
insert.php
CODE
<?
$name = $HTTP_POST_VARS['txtName'];
$title = $HTTP_POST_VARS['txtTitle'];
$message = $HTTP_POST_VARS['txtaMessage'];
/*******************************************************************************
puts name and title into the table
*******************************************************************************/
//include file for the wrapperclass
include "wrapperclass.php";
//make an object of the wrapperclass
$guest=new GuestInterface();
//make db connection
$guestpointer=$guest->connect();
//insert record
$guest->addToGuestBook($name, $title);
$rs = $guest->getUniqID($name, $title);
if ($row=mysql_fetch_assoc($rs))
{
$filename = "guestfiles/guest".$row['ID'].".txt";
}
//disconnect to db
$guest->Disconnect($guestpointer);
/*******************************************************************************
puts message into a file
*******************************************************************************/
//make file and insert content
$guest->makeFile($filename, $message);
//Redirct to the display php
header("Location: display.php");
?>
listguest.php
CODE
<?
//include file for the wrapperclass
include "wrapperclass.php";
//make an object of the wrapperclass
$guest=new GuestInterface();
//make db connection
$guestpointer=$guest->connect();
$rs = $guest->getGuestBook();
while ($row=mysql_fetch_assoc($rs))
{
?>
<br><br>
<table summary="" border="0">
<tr class="head">
<td width="420"><? echo($row['Name']); ?></td>
</tr>
<tr class="main">
<td><? echo($row['Topic']); ?></td>
</tr>
<tr class="main">
<td>
<?
$guest->displayFile("guestfiles/guest".$row['ID'].".txt");
?>
</td>
</tr>
</table>
<?
}
//disconnect to db
$guest->Disconnect($guestpointer);
?>
wrapperclass.php
CODE
<?php
/****************************************************
Wrapper class around mysql database.
*****************************************************/
class GuestInterface
{
/****************************************************
Construct
*****************************************************/
function GuestInterface()
{
}
/*****************************************************************************
Methods for the database
& nbsp;***************************************************************************
***/
/****************************************************
Connects to database
*****************************************************/
function Connect()
{
$host = "localhost";
$username = "usr";
$password = "psw";
$database = "mydb";
$server = mysql_connect($host, $username, $password) or die(mysql_error());
$connection = mysql_select_db($database, $server);
return $server;
}
/****************************************************
Disconnect from database
*****************************************************/
function Disconnect($server)
{
mysql_close($server);
}
/****************************************************
Get info from all the users
*****************************************************/
function getGuestBook()
{
$rs = mysql_query("SELECT * FROM tutGuestBook ORDER BY ID DESC") or die(mysql_error());
return $rs;
}
/****************************************************
Get a uniq id that we will use for making the file
*****************************************************/
function getUniqID($name, $title)
{
$rs = mysql_query("SELECT * FROM tutGuestBook WHERE Name = '$name' AND Topic = '$title' ORDER BY ID DESC") or die(mysql_error());
return $rs;
}
/****************************************************
Add to guestbook
*****************************************************/
function addToGuestBook($name, $title)
{
$sql = mysql_query("INSERT INTO tutGuestBook VALUES ( '', '$name', '$title' ) ")or die(mysql_error());
}
/*****************************************************************************
Methods for making and deleting files
& nbsp;***************************************************************************
***/
/****************************************************
This method make a file, and takes the filename as an argument
*****************************************************/
function makeFile($filename, $content)
{
$content = stripslashes($content);
$fp = fopen($filename,"w") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");
}
/****************************************************
This method display the data in a file
*****************************************************/
function displayFile($filename)
{
if (!file_exists($filename))
{
echo "Couldn't find datafile, please contact administrator!";
}
else
{
$newfile = fopen($filename,"r");
$content = fread($newfile, filesize($filename));
fclose($newfile);
}
$content = stripslashes($content);
$content = htmlentities($content);
$content = nl2br($content);
echo $content;
}
}
?>