Conditionals allow your program to make choices. Following the same sort of boolean logic you just learned about, the computer can only make two choices; true or false. In the case of PHP this is accomplished using IF : ELSE statements. Below is an example of an IF statement that would apply a senior’s discount.
in following statements if $name is premal then all statements inside breckets should be display.
When you are working with PHP, one way to represent data is to use a variable. But sometimes a variable just isn’t enough. Sometimes you need an array. An array is sort of like a variable that holds multiple entries. For example, if you wanted a variable called $state you could only hold one state name. But if you made the same variable an array, you could hold all 50 states.
A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user’s computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.
A cookie is created with the setcookie() function.
Remember one think we have to use cookie before <html> tag.
When you work with an application, you open it, do some changes, and then you close it. This is much like a Session. The computer knows who you are. It knows when you start the application and when you end. But on the internet there is one problem: the web server does not know who you are or what you do, because the HTTP address doesn’t maintain state. Session variables solve this problem by storing user information to be used across multiple pages.
Let’s Start with using sessions.
First of all create a new page named home.php. then at first line you have to write session_start(). It’s a function necessary to use when you are using session. This begins or starts the session.
After that Create simple page which contains textbox & button.
Declaration of the sessions
$_SESSION[‘name of session’]=value;
in above sentence you have to give the name of session & value too.
The above page is home.php
now we pass the value of session to another page that is welcome.php
This is home.php on web browser
When we click on ok then session will pass to welcome.php