Jump to content

PLEASE Tell me what's wrong with my form- Please......


Modernvox

Recommended Posts

Hi Guys, 3 days later and i still can't figure this out...

 

I have small script i created for a local auction house. The client will be entering details like [item Name] [item price] [item qty] and [bidders Id]

 

All bidders are logged in as they arrive through the door. Everything is working fine, but when the client fills in the [item details] with a bidder Id that is NOT logged, I want to issue a warning that allows the opportunity to log the user at that time or NOT. I have created this form, but it does NOTHING at ALL.

 

Please have a look, kick me in the ass and teach me a thing or two would ya , please?

 

<?php
ob_start();
$host= "";
$db_name= "";
$db_user= "";
$db_password= "";

if (isset($_POST['itemDescription'], $_POST['itemPrice'], $_POST['winningBidder'], $_POST['itemQty']))
{
$itemDescription= isset($_POST['itemDescription']) ? $_POST['itemDescription'] : '';
$itemPrice= isset($_POST['itemPrice']) ? $_POST['itemPrice'] : '';
$winningBidder= isset($_POST['winningBidder']) ? $_POST['winningBidder'] : '';
$itemQty= isset($_POST['itemQty']) ? $_POST['itemQty'] : '';

mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM transactions WHERE bidderIds='$winningBidder'"; 
$result=mysql_query($sql);

$count=mysql_num_rows($result);
// If result matched, table row must be 1 row

            if($count==0)
              {
              echo "That Bidder Number is NOT logged in, ";
              echo "would you like to set this bidder as active?";
              echo " Enter 1=NO or 2=YES";
              echo "<form action= \"process_items.php\" method= \"POST\">";
              echo "<input type =\"text\" name= \"logUser\"/>";
              echo "<input type= \"submit\" value = \"Submit\"/>";
              exit();
              }

                      if(isset($_POST['logUser'])) 
                        {
                        $logUser= isset($_POST['logUser']) ? $_POST['logUser'] : '';
                        if ($logUser= 1) {
                        header("Location: inprogress.php");
                        exit();
                        }  /////end if logUser is set
  

                            else if ($logUser= 2){

                                     mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server");
                                     mysql_select_db("$db_name")or die("cannot select DB");
                                     mysql_Query("INSERT INTO bidders (biddersId)
                                     VALUES ('$winningBidder')");
                                     echo $row['winningBidder'];
  
                                     mysql_query("INSERT INTO transactions (itemDescription, itemPrice, bidderId, itemQty , totalPrice) 
                                     VALUES('$itemDescription', '$itemPrice','$winningBidder', '$itemQty', '$totalPrice')")
                                     or die(mysql_error());   
                                     header("Location: inprogress.php");
                                     exit();
                                     } /////////end loguser2
                             }
                   }  //////end if item decription,etc is set
ob_flush();

echo "<font color= \"red\" face=\"calibri\" size=\"4\">That bidder is already logged, Please press your browsers back button and try again.</font>";
?>

 

The script is NOT acknowledging the $logUser variable at ALL, as if the script is not getting that far or reading it. I suspect I am echoing the form wrong? It does however echo

"That Bidder Number is NOT logged in, ";

"would you like to set this bidder as active?";

" Enter 1=NO or 2=YES";

Link to comment
Share on other sites

This is my form

<form action="process_items.php" method="post">
<font face= "calibri" size= "4">
<table border= "1">

<tr style= "background: #cccccc">  <td><b>Item Description:</b></td>
<td><input type= "text" name= "itemDescription" size= "30" value=""/></td>
</tr>
<tr style= "background: #99ff00">   <td><b>Item Price:</b></td>
<td><input type= "text" name= "itemPrice" size= "5" value=""/></td>
</tr>
</tr style= "background: #A8E5FF">   <td><b>Winning Bidders:</b></td>
<td><input type="text" name= "winningBidder" size= "5" /></td>
</tr>
<tr>   <td><b>How many deals?:</b></td>
<td><input type="text" name= "itemQty" size= "3" value= "1" /></td>
</tr>
<br/>
<tr>    <td><input type="reset" value="Reset Form"></td> 
<td><input type="submit" name="submit" value= "submit" /></td>
</tr></font>
</table>
</form>

Link to comment
Share on other sites

Your table has a field called `bidderId`, but your query string is trying to compare to a field called `bidderIds` . . .

 

Just in case you missed this ^ ^ ^ ^

 

Double check that the field names are the correct ones, and not misspelled. It almost has to be something like that causing this problem.

Link to comment
Share on other sites

Your table has a field called `bidderId`, but your query string is trying to compare to a field called `bidderIds` . . .

 

Just in case you missed this ^ ^ ^ ^

 

Thanks. Fixed that. Now everything just equates to "That bidder is already logged, Please press your browsers back button and try again"

Link to comment
Share on other sites

Your table has a field called `bidderId`, but your query string is trying to compare to a field called `bidderIds` . . .

 

Just in case you missed this ^ ^ ^ ^

 

Thanks. Fixed that. Now everything just equates to "That bidder is already logged, Please press your browsers back button and try again"

 

 

 

 

I shouldn't be getting this far down the code if I chose 2 which is to log the bidder and redirect

Link to comment
Share on other sites

How do I echo a Query?

 

 

The same as any other string.

 

echo $sql;

 

I'm NOT using the variable/function $sql though?

 

Of course you are. Right here:

$sql="SELECT * FROM transactions WHERE bidderIds='$winningBidder'"; 
$result=mysql_query($sql);

 

 

HMMMMM... This is what it spit out

SELECT * FROM transactions WHERE bidderId='32'

Link to comment
Share on other sites

Thanks. Fixed that. Now everything just equates to "That bidder is already logged, Please press your browsers back button and try again"

I shouldn't be getting this far down the code if I chose 2 which is to log the bidder and redirect

That echo statement doesn't appear to be in any kind of conditional. In other words, it will echo no matter what happens.

Link to comment
Share on other sites

Thanks. Fixed that. Now everything just equates to "That bidder is already logged, Please press your browsers back button and try again"

I shouldn't be getting this far down the code if I chose 2 which is to log the bidder and redirect

That echo statement doesn't appear to be in any kind of conditional. In other words, it will echo no matter what happens.

 

But all Conditionals are redirect with exit() so how could the last echo still display?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.