Download Intro to PHP

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Zero-configuration networking wikipedia , lookup

Remote Desktop Services wikipedia , lookup

Lag wikipedia , lookup

Cross-site scripting wikipedia , lookup

Hypertext Transfer Protocol wikipedia , lookup

Transcript
COSC 2328 – Web Programming

PHP is a server scripting language

It’s widely-used and free

It’s an alternative to Microsoft’s ASP and Ruby

PHP can run on your ‘Create’ instance
Web Server
Web Browsers
Web pages
rendered
here from
html, css,
images and
javascript
Web Server Software
(e.g., Apache)
www/cosc2328/*.html
/*.php
/css/*.css
/js/*.js
PHP Interpreter
MySQL Database


Name your file with a .php extension
Put the file in your www/cosc2328 folder
<?php
// PHP code goes here
?>
// Many PHP how-to documents show this:
<!DOCTYPE html>
<html>
<body>
<?php
print “<h1>Hello World!</h1>”;
?>
</html>
</body>
</html>
// For this class, do this instead:
<?php
print
“<!DOCTYPE html>\n”.
“<body>\n”.
“
<h1>Hello World!”</h1>\n”.
“</body>\n”.
“</html>”;
?>




PHP superglobals $_GET and $_POST are used to
collect form data
When the user fills out the form and clicks the
‘submit’ button, the form data is sent to the PHP
file for processing
The form data is sent with an HTTP Post or HTTP
Get
You designate whether to use Get or Post in your
web page where you define the form




Hypertext Transfer protocol (http) is designed to enable
communications between clients and servers
http works as a request response protocol between a
client and a server
A web browser may be a client and an application on a
web server may be the server
Example: A client (browser) submits an http request to a
server (web server) and the server does some work and
returns a response




Can be bookmarked
Remains in browser history
Should never be used with sensitive data
Passes data in the Uniform Resource Locator (URL is a
reference address to a resource on the Internet)
Domain
PHP File
Name
Name
|
|
http://foo.com/bar/baz.php?name1=value1&name2=value2
|
|
Protocol
Directory
Name Value Pairs
Passed To PHP Script
(Query String)




Does not remain in browser history
Cannot be bookmarked
Has no restrictions on data length
The query string (name/value pairs) is sent in
the http message body of the post request;
not in the URL
POST /test/demo_form.php HTTP/1.1
Host: foo.com
name1=value1&name2=value2

http://www.jbryan2.create.stedwards.edu/co
sc2328/inClass1.html

http://www.w3schools.com/php/