Topic: empty content?
hi! I am studying php and I found this site very helpful. I copied the codes and tried to do it on my own, changing the data and variables. It was properly working but the only problem that i have is when i added a new record, a new line will be added while having an empty content.
i checked the codes you've provided but its totally the same. what may be the problem?
thanks for the help
here's the code.
<?php
function renderForm($bno, $street, $area, $city, $postcode, $telno, $faxno, $error)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>New BRANCH Record</title>
</head>
<body>
<?php
// if there are any errors, display them
if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>
<form action="" method="post">
<div>
<strong>Branch No.: *</strong> <input type="text" name="firstname" value="<?php echo $bno; ?>" /><br/>
<strong>Street: *</strong> <input type="text" name="lastname" value="<?php echo $street; ?>" /><br/>
<strong>Area: *</strong> <input type="text" name="firstname" value="<?php echo $area; ?>" /><br/>
<strong>City: *</strong> <input type="text" name="lastname" value="<?php echo $city; ?>" /><br/>
<strong>Post Code: *</strong> <input type="text" name="firstname" value="<?php echo $postcode; ?>" /><br/>
<strong>Tel. No.: *</strong> <input type="text" name="lastname" value="<?php echo $telno; ?>" /><br/>
<strong>Fax No.: *</strong> <input type="text" name="firstname" value="<?php echo $faxno; ?>" /><br/>
<p>* required</p>
<input type="submit" name="submit" value="Submit">
</div>
</form>
</body>
</html>
<?php
}
include('connect-db.php');
if (isset($_POST['submit']))
{
$bno = mysql_real_escape_string(htmlspecialchars($_POST['bno']));
$street = mysql_real_escape_string($_POST[$street]);
$area = mysql_real_escape_string(htmlspecialchars($_POST['area']));
$city = mysql_real_escape_string(htmlspecialchars($_POST['city']));
$postcode = mysql_real_escape_string(htmlspecialchars($_POST['postcode']));
$telno = mysql_real_escape_string(htmlspecialchars($_POST['telno']));
$faxno = mysql_real_escape_string(htmlspecialchars($_POST['faxno']));
if ($bno = '' || $street = '' || $area = '' || $city = '' || $postcode = '' || $telno = '' || $faxno = '')
{
$error = 'ERROR: Please fill in all required fields!';
renderForm($bno, $street, $area, $city, $postcode, $telno, $faxno, $error);
}
else
{
mysql_query("INSERT branch SET bno='$bno', street='$street', area='$area', city='$city', postcode='$postcode', telno='$telno', faxno='$faxno'")
or die(mysql_error());
header("Location: branch.php");
}
}
else
{
renderForm('','','','','','','','');
}
?>

