Google App Engine
Feedback on this document

Handling Forms

If we want users to be able to post their own greetings, we need a way to process information submitted by the user with a web form. PHP makes processing form data easy.

Handling Web Forms

Replace the contents of helloworld/helloworld.php with the following:

<html>
  <body>
    <?php
      if (array_key_exists('content', $_POST)) {
        echo "You wrote:<pre>\n";
        echo htmlspecialchars($_POST['content']);
        echo "\n</pre>";
      }
    ?>
    <form action="/sign" method="post">
      <div><textarea name="content" rows="3" cols="60"></textarea></div>
      <div><input type="submit" value="Sign Guestbook"></div>
    </form>
  </body>
</html>

Reload the page to see the form, then try submitting a message.

When the form is submitted, the application receives a request using the HTTP POST method (method="post") and PHP makes POSTed form variables available using the $_POST superglobal.

Let's take a closer look at how the form is processed:

if (array_key_exists('content', $_POST)) {
  echo "You wrote:<pre>\n";
  echo htmlspecialchars($_POST['content']);
  echo "\n</pre>";
}

Before displaying the message (stored in <textarea name="content"), the application checks to see if is present in the $_POST superglobal. If it is then special HTML characters in the message (like "<") are replaced with their corresponding HTML entities (like &lt;) using the htmlspecialchars function.

Next...

Every web application returns dynamically generated HTML from the application code, via templates or some other mechanism. Most web applications also need to serve static content, such as images, CSS stylesheets, or JavaScript files. For efficiency, App Engine treats static files differently from application source and data files. You can use App Engine's static files feature to serve a CSS stylesheet for this application.

Continue to Using Static Files.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.