simple auction bidding form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jenngood
Forum Newbie
Posts: 1
Joined: Mon Jan 14, 2008 4:51 pm

simple auction bidding form

Post by jenngood »

Would love some help with this code. I AM a beginner! I listed an error within the code that I would love help with. Thanks! - Jennifer :D

Code: Select all

 
<?php // Script for CURRENT BID
 
//Turn On Output Buffering
ob_start();
 
// Address error handling
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
 
//Check if the form has been submitted.
 
if (isset ($_POST['submit'])) {
    if ( (!empty ($_POST['first_name']) && (!empty ($_POST['last_name']) && (!empty ($_POST['phone']) && (!empty ($_POST['email']) && (!empty ($_POST['street']) && (!empty ($_POST['city']) && (!empty ($_POST['state']) && (!empty ($_POST['zip']) && (!empty ($_POST['new_bid']) ) {
    print "<p>The Current Bid is $current_bid dollars.</p><p>Please enter a bid equal to the current bid + $100.</p>";
 
 
 
// Fatal error: Unsupported operand types in /home/edwardma/public_html/honoringtheearthseries.com/current_bid.php on line 28 BELOW
 
  
 
if (is_numeric ($new_bid))&& ($new_bid >= ($current_bid + 100)) {
    print "<p>Thank you for your generous bid!  A confirmation email will be sent to you shortly.</p>";
}else{
    print '<p>Please make sure all fields have been entered, that your bid exceeds the current bid by $100 and click the \"Enter My Bid!\" button again, thanks.</p>';
}
}else{
    
// Display the form
 
print "<p>The Current Bid is $current_bid dollars.</p><p>Please enter a bid equal to the current bid + $100.</p>";
print'<form action="current_bid.php" method="post">
<p>First Name: <input type="text" name="first_name" size="20" value="' . $_POST['first_name'] . '" /></p>
<p>Last Name: <input type="text" name="last_name" size="20" value="' . $_POST['last_name'] . '" /></p>
<p>Phone Number: <input type="text" name="phone" size="20" value="' . $_POST['phone'] . '" /></p>
<p>Email Address: <input type="text" name="email" size="30" value="' . $_POST['email'] . '" /></p>
<p>Street Address: <input type="text" name="street" size="30" value="' . $_POST['street'] . '" /></p>
<p>City: <input type="text" name="city" size="30" value="' . $_POST['city'] . '" />State: <input type="text" name="state" size"5" value="' . $_POST['state'] . '" /></p>
<p>Zip: <input type="text" name="zip" size="10" value="' . $_POST['zip'] . '" /></p>
<br />
<p>Enter a Bid: $<input type="text" name="new_bid" size="15" /></form>';
 
$new_bid = ($_POST['new_bid']);
 
$current_bid == $new_bid;
 
</p>
<p><input type="submit" name="submit" value="Enter My Bid!" /></p> 
</body>
</html>
 
if (empty ($new_bid)) {
    print "<p>No bid was entered.  Please hit your back arrow on your browser to return to the previous page and Submit a bid.</p>";
}
 
}else{
    print "<p>Please re-enter your bid to equal the Current Bid + $100.  Press your browser's back arrow to enter your bid.</p>";}
}   
// Add to confirmation email -  We will be making a confirmation telephone call
//Turn off output buffering
ob_end_flush();
?>
 
 
 
User avatar
jimthunderbird
Forum Contributor
Posts: 147
Joined: Tue Jul 04, 2006 3:59 am
Location: San Francisco, CA

Re: simple auction bidding form

Post by jimthunderbird »

wow, a lot of nested if..else...

I think it should be:

Code: Select all

 
 <?php // Script for CURRENT BID
  
 //Turn On Output Buffering
 ob_start();
  
 // Address error handling
 ini_set ('display_errors', 1);
 error_reporting (E_ALL & ~E_NOTICE);
  
 //Check if the form has been submitted.
  
 if (isset ($_POST['submit'])) {
     if (  !empty ($_POST['first_name']) && 
           !empty ($_POST['last_name']) && 
           !empty ($_POST['phone']) && 
           !empty ($_POST['email']) && 
           !empty ($_POST['street']) && 
           !empty ($_POST['city']) && 
           !empty ($_POST['state']) && 
           !empty ($_POST['zip']) && 
           !empty ($_POST['new_bid']) ) {
        print "<p>The Current Bid is $current_bid dollars.</p><p>Please enter a bid equal to the current bid + $100.</p>";
  
  
  
       if ( is_numeric ($new_bid)&& ($new_bid >= ($current_bid + 100)) ) {
           print "<p>Thank you for your generous bid!  A confirmation email will be sent to you shortly.</p>";
       }else{
           print '<p>Please make sure all fields have been entered, that your bid exceeds the current bid by $100 and click the \"Enter My Bid!\" button again, thanks.</p>';
       }
    } 
 }else{
    
 // Display the form
  
 print "<p>The Current Bid is $current_bid dollars.</p><p>Please enter a bid equal to the current bid + $100.</p>";
 print'<form action="current_bid.php" method="post">
 <p>First Name: <input type="text" name="first_name" size="20" value="' . $_POST['first_name'] . '" /></p>
 <p>Last Name: <input type="text" name="last_name" size="20" value="' . $_POST['last_name'] . '" /></p>
 <p>Phone Number: <input type="text" name="phone" size="20" value="' . $_POST['phone'] . '" /></p>
 <p>Email Address: <input type="text" name="email" size="30" value="' . $_POST['email'] . '" /></p>
 <p>Street Address: <input type="text" name="street" size="30" value="' . $_POST['street'] . '" /></p>
 <p>City: <input type="text" name="city" size="30" value="' . $_POST['city'] . '" />State: <input type="text" name="state" size"5" value="' . $_POST['state'] . '" /></p>
 <p>Zip: <input type="text" name="zip" size="10" value="' . $_POST['zip'] . '" /></p>
 <br />
 <p>Enter a Bid: $<input type="text" name="new_bid" size="15" /></form>';
  
 $new_bid = ($_POST['new_bid']);
  
 $current_bid == $new_bid;
 
 print ' 
 </p>
 <p><input type="submit" name="submit" value="Enter My Bid!" /></p>
 </body>
 </html>
 ';
  
   if (empty ($new_bid)) {
       print "<p>No bid was entered.  Please hit your back arrow on your browser to return to the previous page and Submit a bid.</p>";
   }
   else{
       print "<p>Please re-enter your bid to equal the Current Bid + $100.  Press your browser's back arrow to enter your bid.</p>";
   }
 
 } 
 // Add to confirmation email -  We will be making a confirmation telephone call
 //Turn off output buffering
 ob_end_flush();
?>
 
Hope this helps.
Last edited by Weirdan on Mon Jan 14, 2008 8:04 pm, edited 1 time in total.
Reason: switched code -> php tags
Post Reply