The super global variable $_SERVER['PHP_SELF'] always returns the name of the running PHP script. You can rename a script containing the global variable, and your code automatically uses the new script name to process the results.
Solution to Question 10-2
The code to create a username and password form that processes the values is written as follows:
In order to also display the username and password upon submission, specify:
<?php //Get the username and passowrd from the GET global array $username = $_GET["username"]; $password = $_GET["password"]; //determine if this is after the form's been submitted if (!empty($username)){ //display the values from the submission echo ("Username: $username<br>"); echo ("Password: $password<br>"); } else { //display the form echo ('<form action="'.$_SERVER["PHP_SELF"].'" method="GET">'); echo (' <label>Username:<input type="text" name="username" size="10" maxlength="30" /></label> <br> <label>Password:<input type="text" name="password" size="10" maxlength="30" /></label> <input type="submit" value="Submit"> </form>'); } ?>
Solution to Question 10-4
To select only author names starting with an "A", use the following query: