marb Posted October 5, 2013 Share Posted October 5, 2013 Hi, I'm new here and I'm learning PHP. I'm trying to do a little script to print a message after push an HTML button, but the message appears before I push the button. When I have a textbox, I can control that with the instruction" if isset($_Post[text var])", but without the textbox I can't do it. Help me please. Here is the sample: <html> <body> <form " method="post"> <input type="submit" value="Msg" name="submit" /></p> </form> </body> </html> <?php echo "Hello"; ?> Link to comment Share on other sites More sharing options...
Ingolme Posted October 6, 2013 Share Posted October 6, 2013 That's not how PHP works. PHP does all the work on the server before any of the HTML takes relevance. When PHP is done it generates the HTML code and sends it to the user's computer. The computer only sees the HTML. After your PHP script is finished, what's sent to the user is this: <html><body> <form " method="post"> <input type="submit" value="Msg" name="submit" /></p></form></body></html> Hello Learn about forms here: http://w3schools.com/php/php_forms.asp Your <form> needs an action attribute to be useful. In your case, the submit button itself is a form element with name "submit" so you can choose to only show content if that element is found if(isset($_POST[submit'])) { echo "Hello";} Link to comment Share on other sites More sharing options...
marb Posted October 6, 2013 Author Share Posted October 6, 2013 Thank you. I've tried it before, but I didn't put the " " by the variable submit. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now