Jump to content

[SOLVED] Form Submit Image Button Issue in IE7


dlebowski

Recommended Posts

For some reason, the code below works in Firefox just fine.  The form submission goes through.  In IE7, the page refreshes on the submit and it appears that the data is being passed, but it's not adding entry to database.  Any ideas?  Thanks in advance.

 

<td><input type="image" value ="ADD" name="submit3" src="images/tick.png" alt="SUBMIT"></td></form></tr></table><br>

Link to comment
Share on other sites

Best guess is that you ought to test to see if the submit image has been clicked.  The test is actually to check for submit3_x or submit3_y (the coordinates of where the image was clicked). Depending on your form method, check the $_POST or $_GET array.  FYI, that's exactly how an image submit is intended to work - as an image map.  IE got it right.

Link to comment
Share on other sites

I have a feeling that is what the problem is because it doesn't show up in my URL.  Is there what my form does when clicked.  Can you help me with what I need to add to the URL string to get it to capture the cooridanates of the image?  Thanks man.

 

<form action="<? echo "{$_SERVER['PHP_SELF']}?page=$page&SelectDate=$Date&sortby=$sortby" ?>" method="post">

Link to comment
Share on other sites

For a form with method="post" and a submit image NAMEd submit3, the coordinates of where the submit button were clicked will be $_POST['submit3_x'] and $_POST['submit3_y'], both coordinates referencing the upper left corner of the image as 0,0.

 

I don't understand what you mean by adding those to the action (which seems pointless even if it were possible). Why not just process the $_POST data array as well as the $_GET array that's passed by your form's action - which has always seemed a weird way to do things to me when hidden inputs would have worked as well.

Link to comment
Share on other sites

  • 2 weeks later...

Hey Andy.  I went ahead and tested this and it is sending over the values in Firefox, but not IE or Opera.  I used "POST" to grab the data and then just echoed the values back onto the screen. 

 

So knowing that the values are not being submitted, what should my next step be?  I am "under the gun" on this and would appreciate any more suggestions.  Thanks for your help.

Link to comment
Share on other sites

Can you post some code?  The form action line and the form submit lines would be enough from the form; the section of the form processing script to verify that the form has been submitted and code you're using to retrieve all values would also be helpful.

Link to comment
Share on other sites

I think this should do it.  Let me know if you need anything else.  Thanks again for your time.

 

<td><input value ="UPDATE" type="submit" id="addsubmit" name="submit1"></td>
<td><input value ="DELETE" type="submit" id="addsubmit" name="submit2"></td>

 

<form action="<? echo "{$_SERVER['PHP_SELF']}?page=$page&SelectLotAuctionDate=$LotAuctionDate&sortby=$sortby" ?>" method="post">

 

if(isset($_POST['submit1'])){
     
// connect to the database and select the correct database
include("dbinfo.inc.php");
mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

// define each variable
$LotID=$_POST['ud_LotID'];
$LotNumber=$_POST['ud_LotNumber'];
$LotTitle=$_POST['ud_LotTitle'];
$SellingPrice=$_POST['ud_SellingPrice'];
$Buyer=$_POST['ud_Buyer'];
$LotPaymentExempt=$exempt;
$OnlineOnsite=$_POST['ud_OnlineOnsite'];
$AbsenteeBid=$_POST['ud_AbsenteeBid'];
$SellerNumber=$_POST['ud_SellerNumber'];
$LotAuctionDate=$_POST['SelectLotAuctionDate'];

$query = "UPDATE lots SET `LotNumber` = '$LotNumber', `LotTitle` = '$LotTitle', `SellingPrice` = '$SellingPrice', `Buyer` = '$Buyer', `OnlineOnsite` = '$OnlineOnsite', `LotPaymentExempt` = '$LotPaymentExempt', `AbsenteeBid` = '$AbsenteeBid', `SellerNumber` = '$SellerNumber', `LotAuctionDate` = '$LotAuctionDate' WHERE `LotID` = '$LotID'";
mysql_query($query) or die ("Error in query: $query");

echo "<BR><font size=1>$LotNumber UPDATED</font>";

mysql_close();

if(isset($_POST['submit2'])){
     include("dbinfo.inc.php");
mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

// define each variable
$LotID=$_POST['ud_LotID'];
$LotNumber=$_POST['ud_LotNumber'];
mysql_query("DELETE FROM lots WHERE LotID='$LotID'");
echo "<BR><font size=1>$LotNumber DELETED</font>";

mysql_close();

Link to comment
Share on other sites

Just a few observations ....

 

It looks as though you are no longer using images as 'submit' buttons (based on the two td sets you posted) and are back to a conventional submit link.  With the NAME of one button as 'submit1', you are correctly checking for isset($_POST['submit1']).

 

With the form action containing various parameters, I don't see anywhere in your code where you actually retrieve those (from the $_GET array) - and you use at least one of those variables in an sql query in your code.

 

Avoid using the @ error suppression character in your code - let the errors happen since it will improve understanding the problem.

 

Also, at least while testing, echo out the actual queries generated by your code to see if they really contain what you think/hope they contain.

Link to comment
Share on other sites

Also, at least while testing, echo out the actual queries generated by your code to see if they really contain what you think/hope they contain.

 

All the queries contain what they are suppose to when the form is submitted because I confirmed that the data base is updated correctly after the submit for each field.  It will not submit anything correctly when I have the images in there for the buttons.  So it either all is submitted correctly in Firefox or nothing is submitted correctly in other browsers.

 

It looks as though you are no longer using images as 'submit' buttons (based on the two td sets you posted) and are back to a conventional submit link.  With the NAME of one button as 'submit1', you are correctly checking for isset($_POST['submit1']).

 

Here is what it actually is

<td><input type="image" value ="ADD" name="submit1" src="images/tick.png" alt="SUBMIT"></td>
<td><input type="image" value ="ADD" name="submit2" src="images/tick2.png" alt="SUBMIT"></td>

 

 

With the form action containing various parameters, I don't see anywhere in your code where you actually retrieve those (from the $_GET array) - and you use at least one of those variables in an sql query in your code.

 

Here is the "GET" piece.

<?
include("dbinfo.inc.php");
$conn = mysql_connect("localhost",$username,$password) or die(mysql_error()); 
$db = mysql_select_db($database,$conn) or die(mysql_error());

// get the page number or set default 
$page = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] : 1; 

// Define the number of results per page 
$max_results = 10; 

// Figure out the limit for the query based 
// on the current page number. 
$from = (($page * $max_results) - $max_results); 

// going to make some links to click in order for 
// user to sort by whichever column 
$allowed = array('LotNumberASC', 'LotNumberDESC', 'LotTitleASC', 'LotTitleDESC', 'SellingPriceASC', 'SellingPriceDESC','BuyerASC', 'BuyerDESC', 'OnlineOnsiteASC', 'OnlineOnsiteDESC', 'LotPaymentExempt','AbsenteeBidASC', 'AbsenteeBidDESC', 'SellerNumberASC', 'SellerNumberDESC', 'LotAuctionDateASC', 'LotAuctionDateDESC'); 
$sortby = (in_array($_GET['sortby'],$allowed)) ? $_GET['sortby'] : 'LotNumber'; 

// build and run the sql query   
//$query = "select * from customers order by $sortby limit $from, $max_results"; 
//$getlist = mysql_query($query, $conn) or die(mysql_error()); 

// get value of id that sent from form submission
$LotAuctionDate=$_GET['SelectLotAuctionDate'];

if ($sortby=="LotNumberASC") {
$sortby = "LotNumber ASC";
} elseif ($sortby=="LotNumberDESC"){
$sortby = "LotNumber DESC";
} elseif ($sortby=="LotTitleASC"){
$sortby = "LotTitle ASC";
} elseif ($sortby=="LotTitleDESC"){
$sortby = "LotTitle DESC";
} elseif ($sortby=="SellingPriceASC"){
$sortby = "SellingPrice ASC";
} elseif ($sortby=="SellingPriceDESC"){
$sortby = "SellingPrice DESC";
} elseif ($sortby=="BuyerASC"){
$sortby = "Buyer ASC";
} elseif ($sortby=="BuyerDESC"){
$sortby = "Buyer DESC";
} elseif ($sortby=="OnlineOnsiteASC"){
$sortby = "OnlineOnsite ASC";
} elseif ($sortby=="OnlineOnsiteDESC"){
$sortby = "OnlineOnsite DESC";
} elseif ($sortby=="AbsenteeBidASC"){
$sortby = "AbsenteeBid ASC";
} elseif ($sortby=="AbsenteeBidDESC"){
$sortby = "AbsenteeBid DESC";
} elseif ($sortby=="SellerNumberASC"){
$sortby = "SellerNumber ASC";
} elseif ($sortby=="SellerNumberDESC"){
$sortby = "SellerNumber DESC";
} elseif ($sortby=="LotAuctionDateASC"){
$sortby = "LotAuctionDate ASC";
} elseif ($sortby=="LotAuctionDateDESC"){
$sortby = "LotAuctionDate DESC";
}


$sql=" SELECT * FROM lots WHERE LotAuctionDate='$LotAuctionDate' order by $sortby limit $from, $max_results";
$getlist = mysql_query($sql, $conn) or die(mysql_error());
$result=mysql_query($sql);
$num=mysql_numrows($result);


$color1 = '#ebebeb'; 
$color2 = '#ffffff';
$cym="$";
?>

 

 

Link to comment
Share on other sites

input type="image" value ="ADD" name="submit1" src="images/tick.png" alt="SUBMIT">

 

The right way to verify if that image has been clicked is :

 

if (isset($_POST['submit1_x'])) {
    echo "You clicked the ADD image";
    // more code of course
}

 

Note it's buttonname_x (or buttonname_y) that is the value returned in the POST array.  That should work just fine. All other passed variables will be as you have them ($_GET and $_POST).

Link to comment
Share on other sites

Andy,

 

I replaced

 

if(isset($_POST['submit1'])){

 

with

 

if (isset($_POST['submit1_x'])) {

 

and it appears to be working now in IE.  It updates the database just fine.  So do I just leave it as that?  Is that all it was?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.