Hello $name! You are looking ". "at the response of the PHP script.

"; "> Hello $name! You are looking ". "at the response of the PHP script.

"; ">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Executing Server-Side Scripts

Similar presentations


Presentation on theme: "Executing Server-Side Scripts"— Presentation transcript:

1 Executing Server-Side Scripts
We have the following HTML document, name.html, with a form <html> <head> <title>Your Name</title> </head> <body> <form action="name.php" method="post"> <p>Your name: <input type="text" name="name" /> </p> <p><input type="submit"></p> </form> </body> </html>

2 When the form is submitted, the request is fielded by the following PHP script, name.php
$name = $_POST['name']; ?> <html> <head> <title>Your Name, Response</title> </head> <body> echo "<p>Hello $name! You are looking ". "at the response of the PHP script.</p>"; </body> </html>

3 Obviously, name.php must be in the same folder as name.html
If you double click the icon for name.html and fill in the text box, you get something like Note what is in the address bar: the scheme is not http

4 If I click the submit button, I get
The problem is that we didn’t use the HTTP protocol The server never got involved

5 To do it right, start WampServer
Put the 2 files under the document root If you did the default installation of WampServer2, the document root is C:\wamp\www In the browser’s address bar, put localhost denotes the platform the browser is running on The path after is relative to the document root (C:\wamp\www) in the file system

6 So putting http://localhost/name
So putting in the address bar (and hitting return) sends a request to the server to provide the document with full pathname C:\wamp\www\name.html in response

7 We get Note the http scheme

8 If I put Albert in the text box and click the submit button, I now get

9 Suppose I put the 2 files in a subfolder of the document root, say in
C:\wamp\www\c322f09 In the browser’s address bar, after I must have /c322f09/name.html


Download ppt "Executing Server-Side Scripts"

Similar presentations


Ads by Google