Skip to main content

Posts

Showing posts from November 12, 2017

SET, GET AND UNSET SESSION VARIABLES IN PHP

Session is a way to store information across multiple pages in a website. How to start a session: A session can be started  by using session_start() function.We can set session variable by using PHP global variable $_SESSION. consider an example: create a new page demo1.php and start a new PHP session in this page and set some session variables. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 <?php // Start the session session_start (); ?> <!DOCTYPE html> <html> <body> <?php // Set session variables $_SESSION [ "username" ] = "sowmya" ; $_SESSION [ "email" ] = "sowmya.vejerla@gmail.com" ; echo 'username : ' . $_SESSION [ 'username' ]; echo '<br>' ; echo 'email : ' . $_SESSION [ 'email' ]; ?> </body> </html> Next we create another page demo2.php ,from this page we will access  the session variables that we set ...

PHP AND HTML IN ONE PAGE

There are two ways you can use HTML in your PHP page. The first way is  by placing HTML outside the PHP tags.You can put it in the middle if you can open and close PHP tags. Here is an example for it: 1 2 3 4 5 6 7 8 <html> <title>PHP INSIDE HTML</title> <body> <h1>Example</h1> <?php echo "hello world" ?> </body> </html> As you can see you can use any HTML tags without need any extra work,except saving as .php file. The second way is by using PRINT and ECHO statements. Here is an example for it: 1 2 3 4 5 6 7 8 9 <?php Echo "<html>" ; Echo "<title>HTML with PHP</title>" ; Echo "<b>My Example</b>" ; //your php code here Print "<i>Print works too!</i>" ; ?> This is simplest and quick method if you only have a line or so to do.Using both these methods you can embed HTML and PHP in same page to gave them a nice forma...

PHP AND ITS BENEFITS FOR DEVELOPERS

What is PHP and what can it do for our website ? Generally PHP is used to add functionality to our website that HTML alone can't do.However PHP is much more than that! What is PHP? PHP is server-side scripting language.This may seems confusing but it is very clear and straight-forward. What is Server-side scripting language? This means that everything PHP does occurs in server side.As an example, if a user is updating a profile on a networking site, the server-side scripts will gather the information the user enters, the application will process it on the server, then interact with the database to update that information there.And, because PHP is executed on the server, the client cannot view the PHP code. What can PHP do? PHP does anything a PHP programmer wants it to, but it's  main goal is to allow web developers to write dynamically generated pages quickly.  Common uses of PHP include: Perform calculations and mathematical equations Access a wide range of databas...