Hi Could someone help me find where this problem lies, I’ve look at for a missing closing bracket but can’t see it.
[php]<?php
/*
NEW.PHP
Allows user to create a new entry in the database
*/
// creates the new record form
// since this form is used multiple times in this file, I have made it a function that is easily reusable
function renderForm($Name, $Rank, $error)
{
?>
New Record
<?php
// if there are any errors, display them
if ($error != '')
{
echo '
'.$error.'
';
}
?>
Name: * |
|
Rank: |
|
Contact Email: * |
|
Website: (omitting http://) |
|
Location: |
East Midlands
East Of England
Greater London
North East England
North West England
South East England
Soth West England
West Midlands
Yorkshire And The Humber
|
Bio: |
|
|
|
* required
Cancel - View Records
<?php
// connect to the database
include('../connect-db.php');
// check if the form has been submitted. If it has, start to process the form and save it to the database
if (isset($_POST['submit']))
{
// get form data, making sure it is valid
$Name = mysql_real_escape_string(htmlspecialchars($_POST['Name']));
$Rank = mysql_real_escape_string(htmlspecialchars($_POST['Rank']));
$ContactEmail = mysql_real_escape_string(htmlspecialchars($_POST['ContactEmail']));
$Website = mysql_real_escape_string(htmlspecialchars($_POST['Website']));
$Location = mysql_real_escape_string(htmlspecialchars($_POST['Location']));
$BIO = mysql_real_escape_string(htmlspecialchars($_POST['BIO']));
// check to make sure both fields are entered
if ($Name == '' || $ContactEmail == '')
{
// generate error message
$error = 'ERROR: Please fill in all required fields!';
// if either field is blank, display the form again
renderForm($Name, $Rank, $error);
}
else
{
// save the data to the database
mysql_query("INSERT members SET Name='$Name', Rank='$Rank',ContactEmail='$ContactEmail', Website='$Website', Location='$Location', BIO='$BIO'")
or die(mysql_error());
// once saved, redirect back to the view page
header("Location: view.php");
// if the form hasn't been submitted, display the form
renderForm('','','');
}
?> [/php]