View message after sending

advertisements

How can I display an alert after a user clicks a submit button in a form?

I want the alert to show when the page has loaded after the submit button has been clicked.

Is there any way to do this?

EDIT:

I need the message to be HTML text that is displayed on the page--not a javascript alert.


pagewithform.php

<html>
  <head>
  ...
  </head>
  <body>
    ...
    <form action="myformsubmit.php" method="POST">
      <label>Name: <input type="text" name="name" /><label>
      <input type="Submit" value="Submit" />
    </form>
    ...
  </body>
</html>

myformsubmit.php

<html>
  <head>
  ....
  </head>
  <body>
    <?php if (count($_POST)>0) echo '<div id="form-submit-alert">Form Submitted!</div>'; ?>
    ...
  </body>
</html>

EDITED Fits new critieria of OP on last edit.

EDITv2 Try it at home!

<html>
  <head>
    <title>Notify on Submit</title>
  </head>
  <body>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
      <label>Name: <input type="text" name="name" /></label>
      <input type="submit" value="Submit" />
    </form>
    <?php if (count($_POST)>0) echo "Form Submitted!"; ?>
  </body>
</html>

Try that on for size.