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
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
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.