954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

image button to passing value into next page.

i'm newbie in php.

need more help to finish my project..i have 3 page:

1st page : status button(i'm using image button for each status and have 5 status button)
code for image button:

<a href="negeri-semak.php" ><INPUT TYPE="image" value="" src="pictures/icon/image005.gif" width="230" height="37" border="0" id="RAKAN MUDA" onclick="javascript:this.form.submit()" name="BTN" alt="RAKAN MUDA"></a>


2nd page : state button(also image button for each state and have 14 state button)

<a href="search-form.php" ><INPUT TYPE="image" value="" src="pictures/icon/image010.gif" width="230" height="37" border="0" id="MELAKA" onclick="javascript:this.form.submit()" name="BTTN" alt="MELAKA"></a>


3rd page : search form

//status and state chosen from 1st and 2nd page display on top page
<? echo $btn ?> : <? echo $bttn ?>?

//form for search data
<form enctype="multipart/form-data" action="<?=$PHP_SELF?>"  method="post">
<p><span class="style1">Sila masukkan No. Kad Pengenalan anda untuk carian maklumat.</span></p>
        <p>contoh : 880818025434</p>
        <p align="center">&nbsp;</p>
        <p align="center">
          <input name="no_ic" type="text" id="no_ic" maxlength="12" />
          <input type="submit" value="Search" name="cari" id="cari"/>
          <input type="hidden" name="BTN" value="<? echo $btn = $_POST['BTN'] ?>">
          <input type="hidden" name="BTTN" value="<? echo $bttn = $_POST['BTTN'] ?>">
        </p>
      </form>


//php code that i'm using
<?php
$btn = $_POST['BTTN'];
$bttn= $_POST['BTTN'];
$no_ic = $_POST['no_ic'];
if (isset($_POST['cari'])) 
{ 
 if(isset($_POST['no_ic']))
 $data = mysql_query("SELECT * FROM employees where no_ic='{$_POST[ 'no_ic' ]}' AND state='$bttn' AND status='$btn' LIMIT 1") or die(mysql_error()); 
  
 while($info = mysql_fetch_array( $data )) { 

//Outputs the image and other data 
echo "<table border=0 bgcolor=#006699 width=70%><tr><th><img src=images/".$info['photo'] ." alt=" . $info['photo'] . "/></th></tr>"; 
echo "<tr><td><center><table border=0 width=70%><tr><td><b>Name</b></td><td>".$info['name'] . "</td></tr>"; 
echo "<tr><td><b>Number IC</b></th><td>".$info['no_ic'] . "</td></tr>";
echo "<tr><td><b>Email</b></th><td>".$info['email'] . "</td></tr>"; 
echo "<tr><td><b>Phone</b></th><td>".$info['phone'] . " </td></tr>";
echo "<tr><td><b>Address 1</b></td><td> ".$info['address_1'] . "</td></tr> "; 
echo "<tr><td><b>Address 2</b></td><td> ".$info['address_2'] . " </td></tr>"; 
echo "<tr><td><b>Postcode</b></td><td> ".$info['postcode'] . " </td></tr>"; 
echo "<tr><td><b>State</b></td><td> ".$info['state'] . "</td></tr> "; 
echo "<tr><td><b>Status</b></td><td> ".$info['status'] . "</td></tr></center></table></td></tr></table>"; 

$infodata = mysql_num_rows($data);
}

}
  

if ($no_ic == ''){
		echo "<font color='red'>SILA PASTIKAN ANDA MASUKKAN NOMBOR KAD PENGENALAN YANG SAH!";
		} else
		if ($infodata == 0){
		echo "<font color='red'>MAAF, MAKLUMAT YANG DICARI TIADA DALAM PANGKALAN DATA KAMI!";
		}
?>


**MY PROBLEM**

when i use gray button inside dreamweaver it work properly. but when i'm using image button the value for each button did not passing to next page. how can i make my button passing value to next page?i want use every choise from page 1 and 2 to work with my select statement.

//SELECT * FROM employees where no_ic='{$_POST[ 'no_ic' ]}' AND state='$bttn' AND status='$btn';


can anyone help me...? thanks 4 the help.

edz_berlin
Newbie Poster
2 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

You know about , since you are using it. You need to use it on the second page to pass the (now hidden) value from the first page along to the third page.

You also have an extra 'T' on line 21.

Fest3er
Posting Whiz in Training
242 posts since Aug 2007
Reputation Points: 51
Solved Threads: 35
 

You know about , since you are using it. You need to use it on the second page to pass the (now hidden) value from the first page along to the third page.

You also have an extra 'T' on line 21.


thanks 4 info. i already delete that extra T but still cant solve my problem. its still not passing the value. yes i didd used in each of my page, but still not work.

edz_berlin
Newbie Poster
2 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

you have your inside a link
this can be a problem
see:
http://www.quirksmode.org/js/events_order.html
also if this.form.submit() fails you still go to the next page but without the form being send

so remove the link.

pzuurveen
Posting Whiz in Training
229 posts since Sep 2006
Reputation Points: 32
Solved Threads: 47
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: