Download presentation
Presentation is loading. Please wait.
Published byShanon Sanders Modified over 8 years ago
1
Web Forms with PHP COEN 351
2
Displaying and processing a simple form if( array_key_exists(‘my name’,$_POST)){ print “Hello, “.$_POST[‘my_name’]; } else { print <<<_HTML_ Your name: _HTML_; } hello.php
3
Displaying and processing a simple form Web Browser Web Server Get /hello.php Check whether there is a variable my_name in $_POST hash No: Send form
4
Displaying and processing a simple form Web Browser Web Server <form method … No: Send form Your name: Say Hello
5
Displaying and processing a simple form Web Browser Web Server Your name: Say Hello “POST /hello.php” my_name = Emil Emil
6
Displaying and processing a simple form Web Browser Web Server Get /hello.php There is a value for my_name Hello, Emil
7
Displaying and processing a simple form if( array_key_exists(‘my name’,$_POST)){ print “Hello, “.$_POST[‘my_name’]; } else { print <<<_HTML_ Your name: _HTML_; } hello.php
8
Displaying and processing a simple form $_Server is an auto-global array with $_Server[’PHP_Self’] pathname part of the current request’s URL QUERY_STRING part of the URL after ‘?’ character PATH_INFO extra path information tacked onto the end of the URL after the name of the resource SERVER_NAME DOCUMENT_ROOT REMOTE_ADDR REMOTE_HOST HTTP_REFERER HTTP_USER_AGENT $_POST array is an auto-global array: Keys are form element names Values are values of the form elements
9
Displaying and processing a simple form Example is of course horrendously insecure Some functions needed for sanitization: strip_tags removes all html tags html_entities replaces special html characters with their entity equivalents: < to < > to $gt & to & “ to "
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.