Solved

2 Submit Button as a Image help

Posted on 2004-09-27
12
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 2
  • 2
  • +1
12 Comments
 
LVL 27

Expert Comment

by:Diablo84
ID: 12160338
Try with

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

Expert Comment

by:Diablo84
ID: 12160354
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
ID: 12160375
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 49

Expert Comment

by:Roonaan
ID: 12160545
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
ID: 12160572
:)

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

Author Comment

by:Codeit1978
ID: 12160724
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
 
LVL 27

Accepted Solution

by:
Diablo84 earned 50 total points
ID: 12160768
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
ID: 12160786
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
ID: 12160796
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
ID: 12160821
>> 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
ID: 12160839
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
ID: 12164562
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

738 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