The document discusses PHP form handling and validation. It covers using the GET and POST methods to submit form data, and the PHP superglobals like $_GET and $_POST that contain this submitted data. It then discusses validating form fields, including checking for required fields, validating names, emails, and URLs. It provides code examples for validating field values and displaying error messages. It also covers basics of SQL like using CREATE TABLE, INSERT, SELECT, WHERE clauses, and JOINs.
Working with Data and built-in functions of PHPmohanaps
This PPT for PHP covers:
Working with Data
Form and input elements validating the user input, passing variables
between pages, through GET, through POST, through REQUEST and
RESPOND, string functions - chr, ord, strtolower, strtoupper, strlen, ltrim,
rtrim, substr, strcmp, math functions - abs, ceil, floor, round, fmod, min,
max, pow, sqrt, rand, array functions - count, list, in_array, current, next,
previous, end, each, sort, rsort, Rest API.
Working with Data and built-in functions of PHPmohanaps
This PPT for PHP covers:
Working with Data
Form and input elements validating the user input, passing variables
between pages, through GET, through POST, through REQUEST and
RESPOND, string functions - chr, ord, strtolower, strtoupper, strlen, ltrim,
rtrim, substr, strcmp, math functions - abs, ceil, floor, round, fmod, min,
max, pow, sqrt, rand, array functions - count, list, in_array, current, next,
previous, end, each, sort, rsort, Rest API.
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.
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.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
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.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
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.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
2. PHP Form Handling
◦ GET and POST
PHP Form Validation
◦ Validate names
◦ Validate E-mail
◦ Validate URL
3. Superglobals
Superglobals — Built-in variables that are always
available in all scopes
These superglobal variables are:
$GLOBALS
$_SERVER
$_GET
$_POST
$_FILES
$_COOKIE
$_SESSION
$_REQUEST
$_ENV
4. (PHP 4, PHP 5, PHP 7, PHP 8)
$GLOBALS — References all variables
available in global scope
An array containing references to all variables
which are currently defined in the global
scope of the script.
The variable names are the keys of the array.
5. $_SERVER
(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)
$_SERVER — Server and execution
environment information
Description
$_SERVER is an array containing information
such as headers, paths, and script locations.
6. The PHP superglobals $_GET and $_POST are
used to collect form-data.
7.
8.
9. When the user fills out the form above and
clicks the submit button:
The form data is sent for processing to a PHP
file named "welcome.php".
The form data is sent with the HTTP POST
method.
10. To display the submitted data you could simply echo all the variables.
The "welcome.php" looks like this:
11. The same result could also be achieved using
the HTTP GET method:
12.
13. GET vs. POST
Both GET and POST create an array
◦ e.g. array( key1 => value1, key2 => value2, key3
=> value3, ...).
This array holds key/value pairs:
◦ Keys are the names of the form controls
◦ Values are the input data from the user.
14. Both GET and POST are treated as $_GET and
$_POST.
These are superglobals:
◦ which means that they are always accessible,
regardless of scope
- you can access them from any function, class or file
without having to do anything special.
15. But
$_GET is an array of variables passed to the
current script via the URL parameters.
$_POST is an array of variables passed to the
current script via the HTTP POST method.
16. When to use GET?
Information sent from a form with the GET
method is visible to everyone
◦ all variable names and values are displayed in the
URL.
GET also has limits on the amount of
information to send.
◦ The limitation is about 2000 characters.
GET may be used for sending non-sensitive
data.
17. When to use GET?
However, because the variables are displayed
in the URL, it is possible to bookmark the
page.
Note: GET should NEVER be used for sending
passwords or other sensitive information!
18. When to use GET?
A bookmark is a place holder for a web page
that will allow you quick access to that page
instead of having to browse to it or search for
it.
Instead of typing a web page in Google,
clicking the bookmark will direct you to that
page immediately.
19. When to use POST?
Information sent from a form with the POST
method is invisible to others
◦ all names/values are embedded within the body of
the HTTP request
Has no limits on the amount of information
to send.
Moreover POST supports advanced
functionality such as support for multi-part
binary input while uploading files to server.
20. When to use POST?
However, because the variables are not
displayed in the URL, it is not possible to
bookmark the page.
Developers prefer POST for sending form
data.
21. Think SECURITY when processing PHP forms!
Example above does not contain any form
validation, it just shows how you can send
and retrieve form data.
22. The HTML form contains various input fields:
Text fields
◦ Required
◦ Optional
Radio buttons,
A submit button:
25. First we will look at the plain HTML code for
the form:
Text Fields
text input elements
◦ The name
◦ Email
◦ Website
Textarea
◦ comment field is a.
27. Radio Buttons
The gender fields are radio buttons and the
HTML code looks like this:
28. The Form Element
The HTML code of the form looks like this:
When the form is submitted, the form data is sent with
method="post".
29. What is the $_SERVER["PHP_SELF"] variable?
The $_SERVER["PHP_SELF"] is a super global
variable that returns the filename of the
currently executing script.
Sends the submitted form data to the page
itself, instead of jumping to a different page.
This way, the user will get error messages on
the same page as the form.
30. What is the htmlspecialchars() function?
A function converts special characters to
HTML entities.
This means that it will replace HTML
characters like < and > with < and >.
31. This prevents attackers from exploiting the
code by injecting HTML or Javascript code
(Cross-site Scripting attacks) in forms.
32. Validate Form Data With PHP
The first thing we will do is to pass all
variables through PHP's htmlspecialchars()
function.
33. When we use the htmlspecialchars() function;
then if a user tries to submit the following in a
text field:
<script>location.href('http://www.hacked.com')</script>
this would not be executed, because it would be
saved as HTML escaped code, like this:
<script>location.href('http://www.hacked.co
m')</script>
The code is now safe to be displayed on a page
or inside an e-mail.
34. We will also do two more things when the
user submits the form:
Strip unnecessary characters (extra space,
tab, newline) from the user input data (with
the PHP trim() function)
Remove backslashes () from the user input
data (with the PHP stripslashes() function)
35. The next step is to create a function that will
do all the checking for us (which is much
more convenient than writing the same code
over and over again).
Now, we can check each $_POST variable with
the test_input() function
36.
37.
38.
39. We check whether the form has been
submitted using $_SERVER["REQUEST_METHOD".
If the REQUEST_METHOD is POST, then the
form has been submitted - and it should be
validated.
If it has not been submitted, skip the
validation and display a blank form.
40. However, in the example above, all input
fields are optional.
The script works fine even if the user does
not enter any data.
41. PHP Forms - Required Fields
In the previous example the validation rules are:
But in the code above all input fields were optional.
42. PHP - Required Fields
To make a required filed:
1-We have added some new variables:
◦ $nameErr,
◦ $emailErr,
◦ $genderErr,
◦ $websiteErr.
These error variables will hold error messages
for the required fields
43. 2-We have also added an if –else for each
$_POST variable.
This checks if the $_POST variable is empty
using empty() function
◦ If it is empty, an error message is stored in the
different error variables
◦ If it is not empty, it sends the user input data
through the test_input() function
44.
45. PHP - Display The Error Messages
3- Then in the HTML form, we add a little
script after each required field
◦ which generates the correct error message if
needed
46. The <span> HTML element is a generic inline
container for phrasing content, which does
not represent anything.
It can be used to group elements for styling
purposes (using the class or id attributes), or
because they share attribute values
47.
48.
49.
50.
51.
52. PHP - Validate Name
The code below shows a simple way to check
if the name field only contains letters,
dashes, apostrophes and whitespaces. If the
value of the name field is not valid, then store
an error message:
53. $name = test_input($_POST["name"]);
if (!preg_match("/^[a-zA-Z-' ]*$/",$name))
{
$nameErr = "Only letters and white space allowed";
}
The preg_match() function searches a string for
pattern, returning true if the pattern exists, and false
otherwise.
54. PHP - Validate E-mail
The easiest and safest way to check whether
an email address is well-formed is to use
PHP's filter_var() function.
$email = test_input($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$emailErr = "Invalid email format";
}
55. PHP - Validate URL
The code below shows a way to check if a URL
address syntax is valid
◦ this regular expression also allows dashes in the
URL.
If the URL address syntax is not valid, then
store an error message:
58. How to use the CREATE TABLE command to
create a table
How to use the INSERT command to enter
records
How to use the SELECT command to retrieve
records
How to use basic functions, the WHERE
clause, and the GROUP BY clause in SELECT
expressions
59. How to select from multiple tables, using
JOIN
How to use the UPDATE and REPLACE
commands to modify existing records
How to use the DELETE command to remove
records
60. Table Creation Syntax
◦ The table creation command requires
◦ Name of the table
◦ Names of fields
◦ Definitions for each field
The generic table creation syntax is
CREATE TABLE table_name (column_name column_type);
61.
62. Using the INSERT Command
After you have created some tables, you'll use
the SQL command INSERT for adding new
records to these tables.
The basic syntax of INSERT is
INSERT INTO table_name (column list) VALUES (column
values);