Sessions allow a web server to identify clients between page requests. The server assigns each client a unique session ID stored in a cookie. This ID associates multiple requests from the same client as part of the same session. Sessions expire after a period of inactivity to prevent unauthorized access to a logged-in user's session by another user. PHP manages sessions through the session.auto_start and session.gc_maxlifetime settings in php.ini. Session functions like session_start(), session_unset(), and session_destroy() control session behavior.
PHP string function helps us to manipulate string in various ways. There are various types of string function available. Here we discuss some important functions and its use with examples.
PHP string function helps us to manipulate string in various ways. There are various types of string function available. Here we discuss some important functions and its use with examples.
Introduction to java beans, java beans, Core java, j2se, getting started with java beans programming, java to standard edition, beans in java, beans programming in java
Things you should know about Javascript ES5. A programming language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else
This ppt gives a general idea about the multithreading concepts in the java programming language. hope you find it useful
P.S :
sorry there is a correction in one of the slides
where i have entered implements thread
it is wrong it is actually implements Runnable
thank you!
Introduction to java beans, java beans, Core java, j2se, getting started with java beans programming, java to standard edition, beans in java, beans programming in java
Things you should know about Javascript ES5. A programming language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else
This ppt gives a general idea about the multithreading concepts in the java programming language. hope you find it useful
P.S :
sorry there is a correction in one of the slides
where i have entered implements thread
it is wrong it is actually implements Runnable
thank you!
This presentation talks about managing a session and cookies in web using PHP. Cookies are stored at client machine and sent back to the server after first consecutive requests.Session manages the user state on the web page for security purpose as well.
How to Create Login and Registration API in PHP.pdfAppweb Coders
In today’s article, we will explore the concept of REST API and delve into creating a login and registration system using these APIs. In the contemporary landscape of web development, establishing strong and secure authentication systems is of utmost significance. A highly effective approach is to construct a Login and Registration system through the utilization of REST APIs. This article aims to provide you with a comprehensive walkthrough, enabling you to construct a robust and efficient user authentication system from the ground up, harnessing the capabilities of REST architecture.
REST (Representational State Transfer) APIs act as a bridge between the client and the server, facilitating effective communication between them. They utilize HTTP requests to transfer data and are an optimal choice for constructing systems due to their stateless nature. REST APIs provide a seamless integration experience across a variety of platforms and devices.
Before we start coding, ensure you have a development environment set up. Install a web server (e.g., Apache), PHP, and a database (such as MySQL). Organize your project directory and create separate folders for PHP files, configurations, and assets.
Note: In this tutorial, we are utilizing PDO for all database operations. If you are interested in learning about using MySQL or MySQLi, please leave a comment indicating your preference. I will either update this tutorial or create a new article on that topic as well.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Home assignment II on Spectroscopy 2024 Answers.pdf
Php session
1. Sessions
A session begins when a visiting client somehow identifies itself to the web server.
The web server assigns the client a unique session id, which the client uses to re-identify
itself as it moves from page to page on the website. Most of the time, these
unique ids are stored in session cookies that expire after the client hasn't interacted
with the server for some amount of time. The amount of time varies depending on
the web application. For example, an online investment site might have very short
sessions, so that if a user leaves her computer without logging out, another user who
sits down at the same computer several minutes later cannot continue with the first
user's session.
Configuring Sessions
In PHP, session management is configured in the php.ini file. To have a user's session
start as soon as the user visits the website, the session.auto_start flag must be set to 1.
The session length is also set in the php.ini file with the session.gc_maxlifetime
variable. The default value is 1440 seconds (24 minutes).
2. Session Functions
Function Explanation
session_start()
Starts new session if one
does not exist. Continues
current session if one exists.
session_unset() Unsets all session variables.
session_destroy() Kills session.
Ex 1.
<?php
//Begin a session and create a session variable in
//the $_SESSION array.
session_start();
$_SESSION['Greeting'] = 'Hello world!';
echo $_SESSION['Greeting'];
?>
<hr>
<a href="Session2.php">Next page</a>
3. Ex 2.
<?php
//Continue session, show that session variable still
//exists and then unset the session variable
session_start();
echo $_SESSION['Greeting'];
unset($_SESSION['Greeting']);
?>
<a href="Session3.php">Next page</a>
Ex 3.
<?php
//Continue session, show that session variable no longer
//exists and then kill session.
session_start();
echo $_SESSION['Greeting'];
session_unset();
session_destroy();
?>
4. Cookies
Cookies are stored in text files that sit on the client machine. Web pages with the
right permissions can read from and write to cookies. They are generally used to
track user information between visits.
In PHP, cookies are set with the setcookie() function, which can take several
parameters including:
The cookie's name (required).
The cookie's value.
The cookie's expiration date (if this isn't set, the cookie will expire when the
browser window is closed).
The directory path on the server that can read the cookie.
The domain name that can read the cookie.
A flag indicating whether the cookie should only be read over https.
5. Create a Cookie?
The setcookie() function is used to set a cookie.
Note: The setcookie() function must appear BEFORE the <html> tag.
Syntax
setcookie(name, value, expire, path, domain);
Example 1
In the example below, we will create a cookie named "user" and assign the value
"Alex Porter" to it. We also specify that the cookie should expire after one hour:
< ?php
setcookie("user", "Alex Porter", time()+3600);
?>
< html>
.....
Note: The value of the cookie is automatically URLencoded when sending the
cookie, and automatically decoded when received (to prevent URLencoding, use
setrawcookie() instead).
6. Retrieve a Cookie Value?
The PHP $_COOKIE variable is used to retrieve a cookie value.
In the example below, we retrieve the value of the cookie named "user" and display
it on a page:
< ?php
// Print a cookie
echo $_COOKIE["user"];
// A way to view all cookies
print_r($_COOKIE);
?>
In the following example we use the isset() function to find out if a cookie has been
set:
< html>
< body>
< ?php
if (isset($_COOKIE["user"]))
echo "Welcome " . $_COOKIE["user"] . "!<br>";
else
echo "Welcome guest!<br>";
?>
< /body>
< /html>
7. 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.";
?>
8. PHP Mail Form
With PHP, you can create a feedback-form on your website. The example below
sends a text message to a specified e-mail address:
< html>
< body>
< ?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("someone@example.com", $subject,
$message, "From:" . $email);
echo "Thank you for using our mail form";
}
9. else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text'><br>
Subject: <input name='subject' type='text'><br>
Message:<br>
<textarea name='message' rows='15' cols='40'>
</textarea><br>
<input type='submit'>
</form>";
}
?>
< /body>
< /html>
10. What is an Exception
With PHP 5 came a new object oriented way of dealing with errors.
Exception handling is used to change the normal flow of the code execution if a
specified error (exceptional) condition occurs. This condition is called an
exception.
This is what normally happens when an exception is triggered:
The current code state is saved
The code execution will switch to a predefined (custom) exception handler
function
Depending on the situation, the handler may then resume the execution from
the saved code state, terminate the script execution or continue the script from a
different location in the code
We will show different error handling methods:
Basic use of Exceptions
Creating a custom exception handler
Multiple exceptions
Re-throwing an exception
Setting a top level exception handler
11. Use of Exceptions
When an exception is thrown, the code following it will not be executed, and PHP
will try to find the matching "catch" block.
If an exception is not caught, a fatal error will be issued with an "Uncaught
Exception" message.
Lets try to throw an exception without catching it:
< ?php
//create function with an exception
function checkNum($number)
{
if($number>1)
{
throw new Exception("Value must be 1 or below");
}
return true;
}
//trigger exception
checkNum(2);
?>
12. Databases Connection
A database is a collection of information / data that is organized so that it can
easily be retrieved, administrated and updated. Databases thereby enable the
opportunity to create dynamic websites with large amounts of information. For
example, all data on members of argus.net and all posts in the forums are stored
in databases.
There are many different databases: MySQL, MS Access, MS SQL Server, Oracle
SQL Server and many others. In this tutorial, we will use the MySQL database.
MySQL is the natural place to start when you want to use databases in PHP.
If you have a hosted website with PHP, MySQL is probably already installed on
the server.
If you use XAMPP MySQL is already installed and ready to use on your computer.
Just make sure MySQL is running in the Control Panel:
13. In the rest of this lesson, we will look more closely at how you connect to your
database server, before we learn to create databases and retrieve and update data
in the following sessions.
14. Connection to database server
First, you need to have access to the server where your MySQL database is
located. This is done with the function mysql_connect with the following syntax:
mysql_connect(server, username, password)
Example of a MySQL connection with XAMPP (default settings):
mysql_connect("localhost", "root", "") or die (mysql_error());
Create database and tables with phpMyAdmin
It can be useful to be able to create databases and tables directly in PHP. But
often, it will be easier to use phpMyAdmin (or any other MySQL administration
tool), which is standard on most web hosts and XAMPP. The screendumps below
shows how to create a database and tables in phpMyAdmin.
Start by logging onto phpMyAdmin. Often, the address will be the same as your
MySQL server (eg. "http://mysql.myhost.com") and with the same username and
password. In XAMPP, the address is http://localhost/phpmyadmin/.
When you are logged on, simply type a name for the database and press the
button "Create":
15. At some hosts, it's possible the have already created a database, and you may
not have the rights to create more. If that is the case, you obviously just use the
assigned database.
To create a table, click on the tab "Databases" and choose a database by
clicking on it:
16. Then there will be a box titled "Create new table in database", where you type
the name of the table and the number of columns and press the button "Go":
17. Then you can name the columns and set the data type, etc.,
Insert data using SQL
You use MySQL to insert data in a database in the same way that you can use SQL
to create databases and tables. The syntax of the MySQL query is:
INSERT INTO TableName(column1, column2, ...) VALUES(value1, value2, ...)
18. Get data from database
The MySQL query returns a result in the form of a series of records. These
records are stored in a so-called recordset. A recordset can be described as a kind
of table in the server's memory, containing rows of data (records), and each
record is subdivided into individual fields (or columns).
A recordset can be compared to a table where each record could be compared to a
row in the table. In PHP, we can run through a recordset with a loop and the
function mysql_fetch_array, which returns each row as an array.
The code below shows how to use mysql_fetch_array to loop through a recordset:
<html>
<head> <title>Retrieve data from database </title> </head>
<body>
<?php
// Connect to database server
mysql_connect("mysql.myhost.com", "user", "sesame") or die (mysql_error ());
// Select database
mysql_select_db("mydatabase") or die(mysql_error());
// SQL query
$strSQL = "SELECT * FROM people";
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
19. // Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs))
{
// Write the value of the column FirstName (which is now in the array $row)
echo $row['FirstName'] . "<br />";
}
// Close the database connection
mysql_close();
?>
</body>
</html>
20. Delete a record
When deleting a record, you can use the unique AutoNumber field in the
database. In our database, it is the column named id. Using this unique
identifier ensures that you only delete one record. In the next example, we delete
the record where id has the value 24:
<html>
<head> <title>Delete data in the database</title> </head>
<body>
<?php
// Connect to database server
mysql_connect("mysql.myhost.com", "user", "sesame") or die (mysql_error ());
// Select database
mysql_select_db("mydatabase") or die(mysql_error());
// The SQL statement that deletes the record
$strSQL = "DELETE FROM people WHERE id = 24";
mysql_query($strSQL);
// Close the database connection
mysql_close();
?>
<h1>Record is deleted!</h1>
</body> </html>
21. Update cells in the table "people“
The code below updates Donald Duck's first name to D. and changes the phone
number to 44444444. The other information (last name and birthdate) are not
changed. You can try to change the other people's data by writing your own SQL
statements.
<html>
<head> <title>Update data in database</title> </head> <body>
<?php
// Connect to database server
mysql_connect("mysql.myhost.com", "user", "sesame") or die (mysql_error ());
// Select database
mysql_select_db("mydatabase") or die(mysql_error());
// The SQL statement is built
$strSQL = "Update people set ";
$strSQL = $strSQL . "FirstName= 'D.', ";
$strSQL = $strSQL . "Phone= '44444444' ";
$strSQL = $strSQL . "Where id = 22";
// The SQL statement is executed
mysql_query($strSQL);
// Close the database connection
mysql_close();
?>
<h1>The database is updated!</h1> </body> </html>