Now, I've managed to get this sort of thing working before. So, what I did, is I took the original files that I used, went through and changed the information to match my current needs. But it's not working. WHen I run the file, by clicking go on the form, the next page, instead of saying "yes the entry was submitted" or "No it wasn't" it just starts to reel off php, instead of interpriting it. I have the cookie set elsewhere, i'm just trying to get the initial stages working at the moment. Here's my code:
fieldpost.php The form:
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<title>Paint-Zone</title>
</head>
<body class="main" topmargin="0" leftmargin="0">
<div id="banner">
<? include("banner.php"); ?>
</div>
<div id="bodymenu">
<? include("menutable.php"); ?>
</div>
<div id="bodycontent">
<?php
if (isSet($_COOKIE['pzcookie']))
{ ?>
<form action="fields.php" method="post">
Enter the name of the field: <input type="field" name="field" /><br />
Enter the location of the field:
<select name="Location"><br />
<option value="Birmingham">Birmingham</option>
<option value="Manchester">Manchester</option>
<option value="London">London</option>
<option value="North Yorkshire">North Yorkshire</option>
</select><br />
Enter the phone number of the field: <input type="number" name="number" /><br />
Enter the email address of the field: <input type="email" name="email" /><br />
<label>Type a short summary:<br />
<textarea name="summary" rows="10" cols="40">
</textarea></label>
<input type="submit" value="Go!"/>
</form>
<?php
}
else
{
echo 'You do not have permision, bub';
}
?>
</div>
</body>
</html>
fields.php:
<html>
<head>
</head>
<body>
<?php
$dbcnx = @mysql_connect('pathtomydatabase', 'username', 'password');
if (!$dbcnx) {
echo 'Unable to connect to the ' .
'database server at this time.' ;
exit();
}
// Select the database
if (!@mysql_select_db('paintzone')) {
exit('Unable to locate the ' .
'database at this time.');
}
// Write to the fields
if (isset($_POST['summary'])) {
$field= addslashes(htmlentities($_POST['field']));
$location= addslashes(htmlentities($_POST['location']));
$number= addslashes(htmlentities($_POST['number']));
$email= addslashes(htmlentities($_POST['email']));
$summary= addslashes(htmlentities($_POST['summary']));
$sql = "INSERT INTO fields SET
field='$field',
location='$location',
number='$number',
email='$email',
summary='$summary';
if (@mysql_query($sql)) {
echo 'The field has been added';
} else {
echo '<p>Error adding submitted review: ' .
mysql_error() . '</p>';
}
}
// Query All entries
$result = @mysql_query('SELECT * FROM fields');
if (!$result) {
exit('<p>Error performing query: ' .
mysql_error() . '</p>');
}
$number_of_records = mysql_num_rows($result);
$field = mysql_result($result,$number_of_records-1,"field");
$location = mysql_result($result,$number_of_records-1,"location");
$number = mysql_result($result,$number_of_records-1,"number");
$email = mysql_result($result,$number_of_records-1,"email");
$summary = mysql_result($result,$number_of_records-1,"summary");
echo '<table width="600" cellspacing="0" border="2"><tr><td><center>' .$field .'</center></td><td><center>' .location .'<br /></center></td></tr><tr><td colspan="2"><center> ' .$number .' <br /><br /></center></td></tr><tr><td colspan="2"><center>' .$email .'</center></td></tr><tr><td colspan="2"><center>' .$summary .'</center></td></tr></table><br /><br /><br />';
$field = mysql_result($result,$number_of_records-2,"field");
$location = mysql_result($result,$number_of_records-2,"location");
$number = mysql_result($result,$number_of_records-2,"number");
$email = mysql_result($result,$number_of_records-2,"email");
$summary = mysql_result($result,$number_of_records-2,"summary");
echo '<table width="600" cellspacing="0" border="2"><tr><td><center>' .$field .'</center></td><td><center>' .location .'<br /></center></td></tr><tr><td colspan="2"><center> ' .$number .' <br /><br /></center></td></tr><tr><td colspan="2"><center>' .$email .'</center></td></tr><tr><td colspan="2"><center>' .$summary .'</center></td></tr></table><br /><br /><br />';
$field = mysql_result($result,$number_of_records-3,"field");
$location = mysql_result($result,$number_of_records-3,"location");
$number = mysql_result($result,$number_of_records-3,"number");
$email = mysql_result($result,$number_of_records-3,"email");
$summary = mysql_result($result,$number_of_records-3,"summary");
echo '<table width="600" cellspacing="0" border="2"><tr><td><center>' .$field .'</center></td><td><center>' .location .'<br /></center></td></tr><tr><td colspan="2"><center> ' .$number .' <br /><br /></center></td></tr><tr><td colspan="2"><center>' .$email .'</center></td></tr><tr><td colspan="2"><center>' .$summary .'</center></td></tr></table><br /><br /><br />';
?>
</body>
</html>