Summary


This chapter was all about web forms and validating user input. There's a lot more to creating web forms than simply creating HTML controls, and here are some of the salient points in this chapter:

  • The special superglobal array, $_SERVER, contains a great deal of information about what's going on with your web application. $_SERVER['PHP_SELF'] holds the name of the current script, $_SERVER['REQUEST_METHOD'] holds the request method that was used ("GET", "POST", and so on), $_SERVER['HTTP_USER_AGENT'] holds the type of the user's browser, and so on. See Tables 6-1 and 6-2 for the details.

  • In web forms, you can redirect the browser with the header method like this: echo header("Location: new_url.html");.

  • You can combine web forms into one by checking if a user variable is set with the isset function; if so, data is waiting to be processed.

  • PHP provides a variety of ways to validate the data the user sent you, such as using regular expressions on text data.

  • To strip HTML tags, you can use the htmlentities function, which encodes HTML tags.



    Spring Into PHP 5
    Spring Into PHP 5
    ISBN: 0131498622
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net