PHP Rookie - Getting blank page. What am I doing wrong?
Posted: Sun Oct 30, 2005 5:22 pm
Hello again. When I launch this page, I'm getting a blank screen. The full code is below.
The portion that is causing the problem is:
What am I doing wrong?
Code: Select all
<?php
$postItemNum='0123';
if (isset($_POST['submit'])) { // Handle the form.
$message = NULL; // Create an empty new variable.
// Check for a name.
if (strlen($_POST['$Firstname']) > 0) {
$Firstname = TRUE;
} else {
$Firstname = FALSE;
$message .= '<p>You forgot to enter your first name!</p>';
}
// Check for an email address.
if (strlen($_POST['email']) > 0) {
$email = TRUE;
} else {
$email = FALSE;
$message .= '<p>You forgot to enter your email address!</p>';
}
// Check for a Lastname.
if (strlen($_POST['Lastname']) > 0) {
$Lastname = TRUE;
} else {
$Lastname = FALSE;
$message .= '<p>You forgot to enter your last name!</p>';
}
$Bid=0.00;
$Bid=$Bid+$_POST['BidAmount'];
//Check for five dollar increments
if ($Bid]%5)=0 {
$FiveDollar=TRUE;
} else {
$FiveDollar=FALSE;
$message .='<p>All bids must bid in units of $5!</p>';
}
$FiveDollar=TRUE;
$HighBid=TRUE;
if ($Firstname && $email && $Lastname && $HighBid && $FiveDollar) { // If everything's okay.
$message .='The bid worked.';
}
}
// Set the page title and include the HTML header.
?>
<html>
<body>
<?
// Print the error message if there is one.
if (isset($message)) {
echo '<font color="red">', $message, '</font>';
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend>Place Your Bid:</legend>
<p><?php
require_once ("mysql_connect.php");
// Make the query.
$query = "SELECT ItemNum,ItemDesc,HighBid FROM SA_Items where ItemNum='".$postItemNum."'";
$result = @mysql_query ($query); // Run the query.
echo "<table border=1><tr><td><b>ItemNum</b></td><td width=200><b>Item Description</b></td><td><b>Current Bid</b></td></tr>";
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo "<tr>";
echo "<td align=\"left\">$row[0]</td>";
echo "<td align=\"left\">$row[1]</td>";
echo "<td align=\"left\" width=\"200\">$row[2]</td>";
}
mysql_free_result ($result); // Free up the resources.
mysql_close(); // Close the database connection.
?></tr></table></p>
<p><b> First Name:</b> <input type="text" name="Firstname" size="20" maxlength="40" value="<?php if (isset($_POST['Firstname'])) echo $_POST['Firstname']; ?>" /></p>
<p><b> Last Name:</b> <input type="text" name="Lastname" size="20" maxlength="40" value="<?php if (isset($_POST['Lastname'])) echo $_POST['Lastname']; ?>" /></p>
<p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="60" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /> </p>
<p><b>Enter Bid:</b> <input type="text" name="BidAmount" size="40" maxlength="60" value="<?php if (isset($_POST['BidAmount'])) echo $_POST['BidAmount']; ?>" /> </p>
</fieldset>
<div align="center"><input type="submit" name="submit" value="Submit Information" /></div>
</form><!-- End of Form -->
</body>
</html>Code: Select all
$Bid=0.00;
$Bid=$Bid+$_POST['BidAmount'];
//Check for five dollar increments
if ($Bid]%5)=0 {
$FiveDollar=TRUE;
} else {
$FiveDollar=FALSE;
$message .='<p>All bids must bid in units of $5!</p>';
}