Jump to content

[SOLVED] Totally noob need help..


paschim

Recommended Posts

Ok i am just beginning in php/html/...., so please be descriptive in your replies. I was trying to create a simple one page form where there will be 3 to 4 buttons (along with other fields), and clicking on any one of those buttons would submit the form. Then i want to return exactly which button was pressed and show it in a message. i cant figure out how to do this part. if the button types were all "submit" then clicking any one of them will submit the form, but then how do i check which one was pressed exactly?if i am on the wrong path, then please show me the right way!

Link to comment
https://forums.phpfreaks.com/topic/86633-solved-totally-noob-need-help/
Share on other sites

<?php
if ($_POST)
{
if ($_POST['button1'])
	{
	echo "You clicked button 1";	
	}
if ($_POST['button2'])
	{
	echo "You clicked button 2";	
	} 
if ($_POST['button3'])
	{
	echo "You clicked button 3";	
	}
}
else
{?>      
<form name="" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" name="button1" value="Button 1"> <br />
<input type="submit" name="button2" value="Button 2"> <br />
<input type="submit" name="button3" value="Button 3">
</form>
<?php
}
?>

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.