VineetDubey Posted March 7, 2011 Share Posted March 7, 2011 Hi Everyone, can you pls try to find out why this is not working <?php if(isset($_REQUEST['btn'])) { echo "working"; } ?> <html> <body> <input type='Button' name='btn' id='btn' value='Button'> </body> </html> Link to comment https://forums.phpfreaks.com/topic/229863-how-to-check-button-existance-in-php/ Share on other sites More sharing options...
flolam Posted March 7, 2011 Share Posted March 7, 2011 there is no <form> tag around your input Link to comment https://forums.phpfreaks.com/topic/229863-how-to-check-button-existance-in-php/#findComment-1183933 Share on other sites More sharing options...
VineetDubey Posted March 7, 2011 Author Share Posted March 7, 2011 But after adding form tag still it is not working why? Thanks for your reply <?php if(isset($_REQUEST['btn'])) { echo "working"; } ?> <html> <body> <form method='post'> <input type='Button' name='btn' id='btn' value='Button'> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/229863-how-to-check-button-existance-in-php/#findComment-1183954 Share on other sites More sharing options...
flolam Posted March 7, 2011 Share Posted March 7, 2011 You should tell the form what to do: <form action="" method="post"> Link to comment https://forums.phpfreaks.com/topic/229863-how-to-check-button-existance-in-php/#findComment-1183958 Share on other sites More sharing options...
VineetDubey Posted March 7, 2011 Author Share Posted March 7, 2011 But i want code to be in single file . Why should i write action in the <form> tag could you please give me other information on this Link to comment https://forums.phpfreaks.com/topic/229863-how-to-check-button-existance-in-php/#findComment-1183971 Share on other sites More sharing options...
VineetDubey Posted March 7, 2011 Author Share Posted March 7, 2011 Its not working yet.pls help me Link to comment https://forums.phpfreaks.com/topic/229863-how-to-check-button-existance-in-php/#findComment-1183972 Share on other sites More sharing options...
VineetDubey Posted March 7, 2011 Author Share Posted March 7, 2011 This action is also not working Now i have two file one is check.php and test.php In test.php { <html> <body> <form method='post' action='check.php'> <input type='Button' name='btn' id='btn' value='Button'> </form> </body> </html> } In check.php { <?php if(isset($_REQUEST['btn'])) { echo "working"; } ?> } Please help me.I want to know how can i check button click in php. this is working where we replace button with submit button. like <?php if(isset($_REQUEST['btn'])) { echo "working"; } ?> <html> <body> <form method='post'> <input type='submit' name='btn' id='btn' value='Button'> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/229863-how-to-check-button-existance-in-php/#findComment-1183982 Share on other sites More sharing options...
PFMaBiSmAd Posted March 7, 2011 Share Posted March 7, 2011 type='Button' doesn't actually cause anything to happen by itself. You would need to use some javascript. In most cases, you should be using type='submit' Link to comment https://forums.phpfreaks.com/topic/229863-how-to-check-button-existance-in-php/#findComment-1183984 Share on other sites More sharing options...
VineetDubey Posted March 7, 2011 Author Share Posted March 7, 2011 ok thanks for your help Link to comment https://forums.phpfreaks.com/topic/229863-how-to-check-button-existance-in-php/#findComment-1183986 Share on other sites More sharing options...
flolam Posted March 7, 2011 Share Posted March 7, 2011 You don't need to make two files, simply make the action attribute point to its own file, i. e. in test.php: <form action="test.php" method="post"> Additionally, if you only want to check whether the form was submitted, it's better to use if($_SERVER['REQUEST_METHOD'] == "POST") {} (see http://www.vbforums.com/showthread.php?t=562749 ) Link to comment https://forums.phpfreaks.com/topic/229863-how-to-check-button-existance-in-php/#findComment-1184017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.