3 Replies - 261 Views - Last Post: 27 December 2017 - 11:40 PM Rate Topic: -----

#1 madmhan84   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-December 17

How to retain data submitted by two buttons using php?

Posted 27 December 2017 - 09:22 PM

Good day & Happy Holidays :)/>/>

I'd like to ask for a help on how to retain the values that I submitted using two buttons inside a table cell?

This is the result when I click the two buttons in my form:
Output

This is the exact result I wanted (Note: Image below is just edited using picture editor)
Desired Output

This is the code that I used:
<html>
<head>
<title>Sample </title>
</head>
<body>

<table border = "1" align = "center" cellpadding = "10" >
<form method = "post" action = "<?php echo $_SERVER['PHP_SELF']; ?>">

<tr>
<td>Output1 : 
<?php 
	if (isset($_POST['run1'])) {
		echo "<b>" .$_POST['input1']. "</b>"; 
	}	
?> 
</td>

<td>Output2 : 
<?php 
	if (isset($_POST['run2'])) {
		echo "<b>" .$_POST['input2']. "</b>"; 
	}
?>
</td>
</tr>

<tr>
<td><input type = "text" name = "input1" value = "Type here..."></td>
<td><input type = "text" name = "input2" value = "Type here..."></td>
</tr>

<tr>
<td align = "center"><input type = "submit" name = "run1" value = "Button 1"></td>
<td align = "center"><input type = "submit" name = "run2" value = "Button 2"></td>
</tr>

</form>
</table>


</body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: How to retain data submitted by two buttons using php?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14164
  • View blog
  • Posts: 56,756
  • Joined: 12-June 08

Re: How to retain data submitted by two buttons using php?

Posted 27 December 2017 - 09:39 PM

Can't see the pictures.
Was This Post Helpful? 0
  • +
  • -

#3 madmhan84   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-December 17

Re: How to retain data submitted by two buttons using php?

Posted 27 December 2017 - 09:56 PM

View Postmodi123_1, on 27 December 2017 - 09:39 PM, said:

Can't see the pictures.


Image 1 (Output): https://imgur.com/a/qQ8H0

Image 2 (Desired Ouput): https://imgur.com/bmTlOLm

Thank you in advanced! :)
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • Bouncy!
  • member icon

Reputation: 6562
  • View blog
  • Posts: 26,614
  • Joined: 12-December 12

Re: How to retain data submitted by two buttons using php?

Posted 27 December 2017 - 11:40 PM

Question moved to PHP forum.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1