Solved

2 Submit Button as a Image help

Posted on 2004-09-27
12
232 Views
Last Modified: 2008-02-01
I am unable to see what submit button is checked.

I have 2 submit buttons one is Update and the other is addnew.

<input name="UpdateInfo" id="UpdateInfo" type="image" src="arrowforlink2.gif" style="position:absolute; left:341px; top:34px; z-index:3; width:21px; height:19px;">

<input name="AddNew" type="image" src="arrowforlink2.gif" style="position:absolute; left:342px; top:235px; width:21px; height:19px; z-index:4">

Now here is the problem when I hit either of the submit buttons when i try to see which one isset it does not work.  I use a GET to see what vars i was passing and in the query string it gives me
UpdateInfo.x=5&UpdateInfo.y=15   And the same with add new AddNew.x=10&AddNew.y=10

The if(isset($_Get["UpdateInfo"])) does not work.  I even tried it if(isset($_Get["UpdateInfo.X"]))

I take it it is putting the .x and .y because I am using CSS.

Does anyone have any suggestion on how I can determine which submit button has been pressed?

Thanks



//full script code
<?session_start();header("Cache-control: private");

if(isset($_Get["UpdateInfo"]))
{
echo "HI";}else{
$Email = $_SESSION['emailAddress'];
$cID = $_SESSION['uID'];
if($ExistingAddress){
//echo $ExistingAddress;
mysql_connect
("sqlc1.megasqlservers.com","dbm.kargarian.com", "nicole");
@mysql_select_db("TechNo_kargarian_com") or die("Unable to select database");

$result=mysql_query("select * from Bill where BillID = $ExistingAddress");

while($row=mysql_fetch_array($result))
{
$billID = $row['BillID'];
$LoginID = $row['LoginID'];
$FLName =$row['FLName'];
$StreetAddress = $row['StreetAddress'];
$Apt = $row['Apt'];
$Prov = $row['Prov'];
$City = $row['City'];
$Zip = $row['Zip'];
$Country = $row['Country'];
$Phone = $row['Phone'];
$useAS = $row['useAs'];
}

}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link href="Style/UpdatenewDeliveryIE.css" rel="stylesheet" type="text/css">

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<form name="updateBilling" method="GET" action="UpdatenewBilling.php">
<body background="Account%20Login/NEWUpdateNewBilling(800x600.gif">

<div id="Layer1" style="position:absolute; left:293px; top:35px; width:49px; height:16px; z-index:1"><font size="2" face="tahoma"><strong>Update</strong></font>
</div>

<div id="Layer2" style="position:absolute; left:284px; top:235px; width:64px; height:18px; z-index:2"><font size="2" face="tahoma"><strong>
Add New</strong></font> </div>

<input name="UpdateInfo" id="UpdateInfo" type="image" src="arrowforlink2.gif" style="position:absolute; left:341px; top:34px; z-index:3; width:21px; height:19px;">
 
    <select name="ExistingAddress" class="ExAddress" onChange="document.updateBilling.submit()">
<Option>Select Address</Option>
    <?
mysql_connect
("sqlc1.megasqlservers.com","dbm.kargarian.com", "nicole");
@mysql_select_db("TechNo_kargarian_com") or die("Unable to select database");

$result=mysql_query("select BillID, FLName, StreetAddress, Apt, Prov,Phone, City, Zip, Country, useAs from Bill where LoginID = $cID");

while($row=mysql_fetch_array($result))
{//start of while
$billID = $row['BillID'];
$useAS = $row['useAs'];
$StreetAddy = $row['StreetAddress'];

  if($useAS == "AddUseAsBilling"){
?>
<option value="<?echo $billID;?>">
<?PHP echo $StreetAddy;?>
</option>
<?        
     }
}//end of while

?>  
    </select>
  <div class="Billing">
    <input type="radio" name="UseAs" value="rdoUseAsBilling">
  </div>
  <div class="Delivery">
    <input type="radio" name="UseAs" value="rdoUseAsDelivery">
  </div>
  <div class="Both">
    <input type="radio" name="UseAs" value="UseBoth">
  </div>
  <div class="FirstName">
<input type="text" name="txtFLName" class="FirstName" align="texttop"
value="<?echo $FLName;?>">
     </div>
  <p><select name="optCountry" class="Country" >
      <option value="<?echo $Country;?>"><?echo $Country;?></option>
    </select>
    </p>
  <div class="myStreetAddress">
<input type="text" name="txtStreetAddress" class="myStreetAddress" align="texttop" value="<?echo $StreetAddy;?>">
   </div>

<div class="myStateProv">
<input type="text" name="txtStateProv" align="top"  class="myStreetAddress" value="<?echo $Prov?>" >
</div>
  <div class="myApt">
    <input type="text" name="txtApt" class="myApt" value="<?echo $Apt;?>">
  </div>  
  <div class="myCityTown">
    <input type="text" name="txtCityTown" class="myApt" value="<?echo $City;?>">
  </div>
<div class="myPostalCode">
<input type="text" name="txtPostalCode" class="myPostal" style="width:110px" value="<?echo $Zip;?>">
</div>
<input type="radio" name="AddUseAs" value="AddUseAsBilling" class="AddBilling">
<input type="radio" name="AddUseAs" value="AddUseAsDelivery" class="AddDelivery">
<input type="radio" name="AddUseAs" value="AddUseAsBoth" class="AddBoth">
<div class="myContactPhone">
<input type="text" name="txtContactPhone" class="myContactPhone" value="<?echo $Phone;?>">
</div>
<input name="AddNew" type="image" src="arrowforlink2.gif" style="position:absolute; left:342px; top:235px; width:21px; height:19px; z-index:4">
  </form>
</body>
</html>
<?}?>

0
Comment
Question by:Codeit1978
  • 7
  • 2
  • 2
  • +1
12 Comments
 
LVL 27

Expert Comment

by:Diablo84
Comment Utility
Try with

if(isset($_Get["UpdateInfo_X"]))
0
 
LVL 27

Expert Comment

by:Diablo84
Comment Utility
Note: for debugging purposes add print_r($_POST); or print_r($_GET); in your case to see what the post and get arrays contain. You can then observe the array keys to see the value you should be checking for.
0
 
LVL 27

Expert Comment

by:Diablo84
Comment Utility
Note2: In Firefox/Mozilla if(isset($_Get["UpdateInfo"])) should work however in IE the value of the image is not posted (and subsequently there is no key for the elements name). This has just caused me a major headache... as IE has done on many occasions.
0
 
LVL 49

Expert Comment

by:Roonaan
Comment Utility
As alternative to Diablo's suggestion you could use javascript:

Change:
<input name="AddNew" type="image" src="arrowforlink2.gif" style="position:absolute; left:342px; top:235px; width:21px; height:19px; z-index:4">

into
<input type="hidden" name="submitbutton" value="" />
<input name="AddNew" type="image" src="arrowforlink2.gif" style="position:absolute; left:342px; top:235px; width:21px; height:19px; z-index:4" onclick="this.form.submitbutton.value=this.name" />

Then you could use if($_GET['submitbutton'] == 'AddNew') instead of issets.

This doesn't work on browsers which don't support javascript obviously.

Regards

-r-

<observation>Diable84, are you trying to set some kind of posting record here? </observation>
0
 
LVL 27

Expert Comment

by:Diablo84
Comment Utility
:)

A case of delayed after thought followed by a delayed delayed after though.
0
 
LVL 1

Author Comment

by:Codeit1978
Comment Utility
I did the print r command and got:

[UpdateInfo_x] => 5 [UpdateInfo_y] => 17

When I did if(isset($_Get["UpdateInfo_y"])) or if(isset($_Get["UpdateInfo_x"])) it did not work.

I just may have to go with javascript.  Any other suggestions?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 27

Accepted Solution

by:
Diablo84 earned 50 total points
Comment Utility
hmm, just tested with:

<?php
if (isset($_GET['UpdateInfo_x'])) echo "UpdateInfo Clicked";
if (isset($_GET['AddNew_x'])) echo "AddNew Clicked";
?>
<form action="/a.php" method="get">
<input name="UpdateInfo" id="UpdateInfo" type="image" src="arrowforlink2.gif" style="position:absolute; left:341px; top:34px; z-index:3; width:21px; height:19px;">
<input name="AddNew" type="image" src="arrowforlink2.gif" style="position:absolute; left:342px; top:235px; width:21px; height:19px; z-index:4">
</form>

works fine in IE and Firefox
0
 
LVL 27

Expert Comment

by:Diablo84
Comment Utility
You could also try with:

if (array_key_exists("UpdateInfo_x",$_GET))

instead of

if(isset($_Get["UpdateInfo_x"]))

but the latter should work fine
0
 
LVL 1

Author Comment

by:Codeit1978
Comment Utility
Diablo84,  Thanks I think I may have got it to work.

let me play with it for a sec to make sure it is working corretly,  it will work using a post aswell correct?
0
 
LVL 27

Expert Comment

by:Diablo84
Comment Utility
>> it will work using a post aswell correct?

yes, post and get are both essentially arrays so the same principles apply to both in this case.
0
 
LVL 49

Expert Comment

by:Roonaan
Comment Utility
strpos(strtolower(implode('',array_keys($_GET))), 'updateinfo')

and

strpos(strtolower(implode('',array_keys($_GET))), 'addnew') could work also :)

-r-
0
 
LVL 48

Expert Comment

by:hernst42
Comment Utility
Just a note:
The Problem with your code is that the superglobal $_Get does not exists. It's $_GET, so if you change the variable $_Get to uppercase it should work.

If you don't want to care about how the form was subitted by post or get you can use $_REQUEST which combines the $_GET, $_POST, $_COOKIE to one array.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now