In: Computer Science
PHP
Review
For the Programming part:
1. Where (Which directory) you store the database connecting information? parallel to htdocs folder why? no one can access except the admin
2. difference between GET and POST methods
3. Include multiple files: include, include_once, require, require_once
4. what is a sticky form?
2.
The GET Method
GET is used to request data from a specified resource.
GET is one of the most common HTTP methods.
Note that the query string (name/value pairs) is sent in the URL of a GET request:
/test/demo_form.php?name1=value1&name2=value2
Some other notes on GET requests:
The POST Method
POST is used to send data to a server to create/update a resource.
The data sent to the server with POST is stored in the request body of the HTTP request:
POST /test/demo_form.php HTTP/1.1
Host: w3schools.com
name1=value1&name2=value2
POST is one of the most common HTTP methods.
Some other notes on POST requests:
3.
The “include” php statement is used to include other files into a PHP file. It has two variations, include and include_once. Include_once is ignored by the PHP interpreter if the file to be included.The include statement has the following syntax
<?php include 'file_name'; ?>
The include_once statement has the following syntax
<?php include_once 'file_name'; ?>
HERE,
Example : Include / Include_once
Suppose you are developing a website that contains the same navigation menu across all the pages.You can create a common header then include it in every page using the include statement Let’s see how this can be done.We will create 2 files names header.php, index.php
Below are the codes for; header.php
<a href="/index.php">Home</a> <a href="/aboutus.php">About us</a> <a href="/services.php">Services</a> <a href="/contactus.php">Contact Us</a>
index.php
<?php include 'header.php'; ?>
The header page above will output PHP Require & PHP require_once The require statement has two variations, require and require_once.The require/require_once statement is used to include file.Require_once is ignored if the required file has already been added by any of the four include statements.It has the following syntax
<?php require 'file_name'; ?>
<?php require_once 'file_name'; ?>
HERE,
4.A sticky form is simply a standard HTML form that remembers how you filled it out. This is a particularly nice feature for end users, especially if you are requiring them to resubmit a form. With this in mind, I'll rewrite register.php one final time so that it's stickier.