I want to have a php contact form, that when submitted (if no errors), will refresh the same page, and remove the contact form, and replace it with some text e.g. "thank you for contacting us". Is there a best way to do this?
2条回答 默认 最新
doukuizuo1795 2013-01-03 23:26关注You could always do something like this:
<?php $posted = false; if( isset($_POST['submit']) ) { /* Process $_POST */ /* Do your things */ /* Set a variable hinting if a post has been done */ $posted = true; } ?> <!DOCTYPE html> <html> <body> <?php if( $posted ): ?> <form method="post"> <input name="foo" /> <input name="bar" /> <input name="car" /> <input name="submit" type="submit" value="Submit" /> </form> <?php else: ?> <h1>Thank you for contacting us!</h1> <?php endif; ?> </body> </html>解决 无用评论 打赏 举报