Show how authorization works in PHP

<?php
// define $authorized = true only if user is authenticated
if (authenticated_user()) { $authorized = true; }
// Because we didn't first initialize $authorized as false, this might be
// defined through register_globals, like from GET auth.php?authorized=1
// So, anyone can be seen as authenticated!
if ($authorized) { include "/highly/sensitive/data.php"; }?>

What is Session in PHP?

A PHP session variable is used to store information about, or change settings for a user session. Session variables hold information about one single user, and are available to all pages in one application.

<?php session_start();?>
<html>
<body></body></html>

What is Cookies in PHP?

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.

<?php
setcookie("user", "Alex Porter", time()+3600);
?>
<html>

Show how to make Mail in PHP.

The PHP mail() function is used to send emails from inside a script.

Syntax

mail(to,subject,message,headers,parameters)

PHP Simple E-Mail

The simplest way to send an email with PHP is to send a text email.

In the example below we first declare the variables ($to, $subject, $message, $from, $headers), then we use the variables in the mail() function to send an e-mail:

<?php $to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:". $from;
mail($to,$subject,$message,$headers); echo "Mail Sent.";?>

Show main differences between Client and Server Side scripting languges?

An HTML file can contain HTML tags, text and scripts.

Server-side scripting is about "programming" the behavior of the server. This is called server-side scripting or server scripting.

Client-side scripting is about "programming" the behavior of the browser. (see Web JavaScript chapter).

Normally, when a browser requests an HTML file, the server returns the file. However, if the file contains a server-side script, the script is executed on the server before the file is returned to the browser as plain HTML.


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: