SlideShare una empresa de Scribd logo
1 de 12
1 
44 You have been added to the 
45 <span style = "color: blue"> 
46 <strong> 
47 <?php print( "$book " ); ?> 
48 </strong> 
49 </span> 
50 mailing list. 
51 </p> 
52 <strong>The following information has been saved 
53 in our database:</strong><br /> 
54 
55 <table border = "0" cellpadding = "0" cellspacing = "10"> 
56 <tr> 
57 <td bgcolor = "#ffffaa">Name </td> 
58 <td bgcolor = "#ffffbb">Email</td> 
59 <td bgcolor = "#ffffcc">Phone</td> 
60 <td bgcolor = "#ffffdd">OS</td> 
61 </tr> 
62 
63 <tr> 
64 <?php 
65 
form.php 
(3 of 4)
2 
form.php 
(4 of 4) 
66 // print each form field’s value 
67 print( "<td>$fname $lname</td> 
68 <td>$email</td> 
69 <td>$phone</td> 
70 <td>$os</td>" ); 
71 ?> 
72 </tr> 
73 </table> 
74 
75 <br /><br /><br /> 
76 <div style = "font-size: 10pt; text-align: center"> 
77 This is only a sample form. 
78 You have not been added to a mailing list. 
79 </div> 
80 </body> 
81 </html>
3 
26.5 Form Processing and Business 
Logic 
Fig. 26.14 Obtaining user input through forms.
4 
26.6 Verifying a Username and 
Password 
 Private website 
 Only accessible to certain individuals 
 Encrypt username and password data when 
sending, storing and retrieving for increased 
security 
 Implementing password checking 
 Login information stored in file 
• fopen function 
 Read, write, append modes 
 Store data using fputs 
• n newline character 
 Close files when done 
• fclose function
5 
26.6 Verifying a Username and 
Password 
 Implementing password checking, cont. 
 Trim newline character 
• chop function 
 Split string into substrings given a certain 
delimiter 
• split function 
 If username/password match list, allow access
6 
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
3 
4 <!-- Fig. 26.15: password.html --> 
5 <!-- XHTML form sent to password.php for verification --> 
6 
7 <html xmlns = "http://www.w3.org/1999/xhtml"> 
8 <head> 
9 <title>Verifying a username and a password.</title> 
10 
11 <style type = "text/css"> 
12 td { background-color: #DDDDDD } 
13 </style> 
14 </head> 
15 
16 <body style = "font-family: arial"> 
17 <p style = "font-size: 13pt"> 
18 Type in your username and password below. 
19 <br /> 
20 <span style = "color: #0000FF; font-size: 10pt; 
21 font-weight: bold"> 
22 Note that password will be sent as plain text 
23 </span> 
24 </p> 
25 
password.html 
(1 of 4)
7 
26 <!-- post form data to password.php --> 
27 <form action = "password.php" method = "post"> 
28 <br /> 
29 
30 <table border = "0" cellspacing = "0" 
31 style = "height: 90px; width: 123px; 
32 font-size: 10pt" cellpadding = "0"> 
33 
34 <tr> 
35 <td colspan = "3"> 
36 <strong>Username:</strong> 
37 </td> 
38 </tr> 
39 
40 <tr> 
41 <td colspan = "3"> 
42 <input size = "40" name = "USERNAME" 
43 style = "height: 22px; width: 115px" /> 
44 </td> 
45 </tr> 
46 
password.html 
(2 of 4) 
Form data is posted to password.php.
8 
47 <tr> 
48 <td colspan = "3"> 
49 <strong>Password:</strong> 
50 </td> 
51 </tr> 
52 
53 <tr> 
54 <td colspan = "3"> 
55 <input size = "40" name = "PASSWORD" 
56 style = "height: 22px; width: 115px" 
57 type = "password" /> 
58 <br/></td> 
59 </tr> 
60 
61 <tr> 
62 <td colspan = "1"> 
63 <input type = "submit" name = "Enter" 
64 value = "Enter" style = "height: 23px; 
65 width: 47px" /> 
66 </td> 
67 <td colspan = "2"> 
68 <input type = "submit" name = "NewUser" 
69 value = "New User" 
70 style = "height: 23px" /> 
71 </td> 
password.html 
(3 of 4)
9 
72 </tr> 
73 </table> 
74 </form> 
75 </body> 
76 </html> 
password.html 
(4 of 4)
10 
26.6 Verifying a Username and 
Password 
Fig. 26.15 XHTML form for obtaining a username and password.
11 
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
3 
4 <!-- Fig. 26.16: password.php --> 
5 <!-- Searching a database for usernames and passwords. --> 
6 
7 <html xmlns = "http://www.w3.org/1999/xhtml"> 
8 <head> 
9 <?php 
10 extract( $_POST ); 
11 
12 // check if user has left USERNAME or PASSWORD field blank 
13 if ( !$USERNAME || !$PASSWORD ) { 
14 fieldsBlank(); 
15 die(); 
16 } 
17 
18 // check if the New User button was clicked 
19 if ( isset( $NewUser ) ) { 
20 
21 // open password.txt for writing using append mode 
22 if ( !( $file = fopen( "password.txt", 
23 "a" ) ) ) { 
24 
password.php 
(1 of 7) 
Variable names, when preceded by the logical 
negation operator (!), return true if they are empty 
or set to 0. This checks if a user has submitted a form 
without specifying a username or password. 
Function fieldsBlank is called if the user has 
submitted an incomplete form to notify the user 
that all form fields must be completed. 
Function isset tests whether the user has 
pressed the New User button, indicating that a 
new user must be added. 
To add a new user, we open the file 
password.txt in append mode and assign the 
file handle that is returned to variable $file.
12 
25 // print error message and terminate script 
26 // execution if file cannot be opened 
27 print( "<title>Error</title></head><body> 
28 Could not open password file 
29 </body></html>" ); 
30 die(); 
31 } 
32 
33 // write username and password to file and 
34 // call function userAdded 
35 fputs( $file, "$USERNAME,$PASSWORDn" ); 
36 userAdded( $USERNAME ); 
37 } 
38 else { 
39 
40 // if a new user is not being added, open file 
41 // for reading 
42 if ( !( $file = fopen( "password.txt", 
43 "r" ) ) ) { 
44 print( "<title>Error</title></head> 
45 <body>Could not open password file 
46 </body></html>" ); 
47 die(); 
48 } 
49 
password.php 
Print an error message and terminate sc(r2ip otf e 7x)ecution 
if the file cannot be opened. 
Function userAdded is called to print a message to the 
user to indicate that the username and password were 
added to the file. 
Function fputs writes the name and password to the 
text file..

Más contenido relacionado

La actualidad más candente

Java script frame window
Java script frame windowJava script frame window
Java script frame windowH K
 
14922 java script built (1)
14922 java script built (1)14922 java script built (1)
14922 java script built (1)dineshrana201992
 
Web app development_html_02
Web app development_html_02Web app development_html_02
Web app development_html_02Hassen Poreya
 
Html basics 11 form validation
Html basics 11 form validationHtml basics 11 form validation
Html basics 11 form validationH K
 

La actualidad más candente (6)

Java script frame window
Java script frame windowJava script frame window
Java script frame window
 
14922 java script built (1)
14922 java script built (1)14922 java script built (1)
14922 java script built (1)
 
Practica n° 7
Practica n° 7Practica n° 7
Practica n° 7
 
Web app development_html_02
Web app development_html_02Web app development_html_02
Web app development_html_02
 
Java script programms
Java script programmsJava script programms
Java script programms
 
Html basics 11 form validation
Html basics 11 form validationHtml basics 11 form validation
Html basics 11 form validation
 

Destacado

Instalaciones Uelam
Instalaciones UelamInstalaciones Uelam
Instalaciones UelamChris Paúl
 
[1] sk kd pai sma xi
[1] sk kd pai sma xi[1] sk kd pai sma xi
[1] sk kd pai sma xiawalsepta84
 
Resep Masakan Indonesia
Resep Masakan IndonesiaResep Masakan Indonesia
Resep Masakan IndonesiaMartha Doane
 
Dinamica social monografia
Dinamica social monografiaDinamica social monografia
Dinamica social monografiaEnrique Cobos
 
STEM Programs for Children
STEM Programs for ChildrenSTEM Programs for Children
STEM Programs for ChildrenCicely Douglas
 
Constitutional validity of section 497 ipc
Constitutional validity of section 497 ipc Constitutional validity of section 497 ipc
Constitutional validity of section 497 ipc Shantanu Basu
 
ウェアラブル端末のセンサ値から動きをリアルタイムに識別する(Wi p)
ウェアラブル端末のセンサ値から動きをリアルタイムに識別する(Wi p)ウェアラブル端末のセンサ値から動きをリアルタイムに識別する(Wi p)
ウェアラブル端末のセンサ値から動きをリアルタイムに識別する(Wi p)新 古川
 
MaruLaboの紹介
MaruLaboの紹介MaruLaboの紹介
MaruLaboの紹介Naoya Niwa
 
[Revit] Family ký hiệu đường ống nước
[Revit] Family ký hiệu đường ống nước[Revit] Family ký hiệu đường ống nước
[Revit] Family ký hiệu đường ống nướcHuytraining
 
Sensory physiology
Sensory physiologySensory physiology
Sensory physiologyChy Yong
 
ความหมายของโครงงานคอมพิวเตอร์
ความหมายของโครงงานคอมพิวเตอร์ความหมายของโครงงานคอมพิวเตอร์
ความหมายของโครงงานคอมพิวเตอร์Kornkaruna Lawanyakul
 
7 สามัญ คณิต เฉลย
7 สามัญ คณิต เฉลย7 สามัญ คณิต เฉลย
7 สามัญ คณิต เฉลยKornkaruna Lawanyakul
 
The path that leads to a blissful and healthy lifestyle
The path that leads to a blissful and healthy lifestyleThe path that leads to a blissful and healthy lifestyle
The path that leads to a blissful and healthy lifestyleEason Chan
 

Destacado (20)

Instalaciones Uelam
Instalaciones UelamInstalaciones Uelam
Instalaciones Uelam
 
[1] sk kd pai sma xi
[1] sk kd pai sma xi[1] sk kd pai sma xi
[1] sk kd pai sma xi
 
Resep Masakan Indonesia
Resep Masakan IndonesiaResep Masakan Indonesia
Resep Masakan Indonesia
 
New Nordic Leadership - dansk
New Nordic Leadership - danskNew Nordic Leadership - dansk
New Nordic Leadership - dansk
 
Dinamica social monografia
Dinamica social monografiaDinamica social monografia
Dinamica social monografia
 
STEM Programs for Children
STEM Programs for ChildrenSTEM Programs for Children
STEM Programs for Children
 
Adultery is a sin
Adultery is a sinAdultery is a sin
Adultery is a sin
 
Constitutional validity of section 497 ipc
Constitutional validity of section 497 ipc Constitutional validity of section 497 ipc
Constitutional validity of section 497 ipc
 
Infographic: Pancreatic Cancer by the Numbers
Infographic: Pancreatic Cancer by the NumbersInfographic: Pancreatic Cancer by the Numbers
Infographic: Pancreatic Cancer by the Numbers
 
3.2 probablity
3.2 probablity3.2 probablity
3.2 probablity
 
2.2 pict of data
2.2 pict of data2.2 pict of data
2.2 pict of data
 
ウェアラブル端末のセンサ値から動きをリアルタイムに識別する(Wi p)
ウェアラブル端末のセンサ値から動きをリアルタイムに識別する(Wi p)ウェアラブル端末のセンサ値から動きをリアルタイムに識別する(Wi p)
ウェアラブル端末のセンサ値から動きをリアルタイムに識別する(Wi p)
 
3.1 probability
3.1 probability3.1 probability
3.1 probability
 
MaruLaboの紹介
MaruLaboの紹介MaruLaboの紹介
MaruLaboの紹介
 
Building a Program in Personalized Medicine
Building a Program in Personalized Medicine Building a Program in Personalized Medicine
Building a Program in Personalized Medicine
 
[Revit] Family ký hiệu đường ống nước
[Revit] Family ký hiệu đường ống nước[Revit] Family ký hiệu đường ống nước
[Revit] Family ký hiệu đường ống nước
 
Sensory physiology
Sensory physiologySensory physiology
Sensory physiology
 
ความหมายของโครงงานคอมพิวเตอร์
ความหมายของโครงงานคอมพิวเตอร์ความหมายของโครงงานคอมพิวเตอร์
ความหมายของโครงงานคอมพิวเตอร์
 
7 สามัญ คณิต เฉลย
7 สามัญ คณิต เฉลย7 สามัญ คณิต เฉลย
7 สามัญ คณิต เฉลย
 
The path that leads to a blissful and healthy lifestyle
The path that leads to a blissful and healthy lifestyleThe path that leads to a blissful and healthy lifestyle
The path that leads to a blissful and healthy lifestyle
 

Similar a Synapse india basic php development part 2

JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions Reem Alattas
 
Rounded Shaped Box Example 1
Rounded Shaped Box Example 1Rounded Shaped Box Example 1
Rounded Shaped Box Example 1Sibananda Panda
 
A simple html login page using java s
A simple html login page using java sA simple html login page using java s
A simple html login page using java sJoel Bisonzi
 
Webpro2 pert6 7_login_menu_
Webpro2 pert6 7_login_menu_Webpro2 pert6 7_login_menu_
Webpro2 pert6 7_login_menu_Sejahtera Affif
 
Dynamic HTML Event Model
Dynamic HTML Event ModelDynamic HTML Event Model
Dynamic HTML Event ModelReem Alattas
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivityMouli Chandira
 
Web Application PHP and MySQL Database
Web Application PHP and MySQL DatabaseWeb Application PHP and MySQL Database
Web Application PHP and MySQL DatabaseSunny U Okoro
 
krish (1).pdf
krish (1).pdfkrish (1).pdf
krish (1).pdfKrish11A
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemAzharul Haque Shohan
 

Similar a Synapse india basic php development part 2 (20)

JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions
 
Rounded Shaped Box Example 1
Rounded Shaped Box Example 1Rounded Shaped Box Example 1
Rounded Shaped Box Example 1
 
A simple html login page using java s
A simple html login page using java sA simple html login page using java s
A simple html login page using java s
 
Synapse india basic php development part 1
Synapse india basic php development part 1Synapse india basic php development part 1
Synapse india basic php development part 1
 
Webpro2 pert6 7_login_menu_
Webpro2 pert6 7_login_menu_Webpro2 pert6 7_login_menu_
Webpro2 pert6 7_login_menu_
 
Dynamic HTML Event Model
Dynamic HTML Event ModelDynamic HTML Event Model
Dynamic HTML Event Model
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
The Devil and HTML5
The Devil and HTML5The Devil and HTML5
The Devil and HTML5
 
Insertcustomer
InsertcustomerInsertcustomer
Insertcustomer
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
Fcr 2
Fcr 2Fcr 2
Fcr 2
 
Web technology lab manual
Web technology lab manualWeb technology lab manual
Web technology lab manual
 
PHP Scripting
PHP ScriptingPHP Scripting
PHP Scripting
 
Web Application PHP and MySQL Database
Web Application PHP and MySQL DatabaseWeb Application PHP and MySQL Database
Web Application PHP and MySQL Database
 
krish (1).pdf
krish (1).pdfkrish (1).pdf
krish (1).pdf
 
Update statement in PHP
Update statement in PHPUpdate statement in PHP
Update statement in PHP
 
Html5 intro
Html5 introHtml5 intro
Html5 intro
 
Pl sql using_xml
Pl sql using_xmlPl sql using_xml
Pl sql using_xml
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login System
 
Tutorial asp.net
Tutorial  asp.netTutorial  asp.net
Tutorial asp.net
 

Más de Synapseindiappsdevelopment

Synapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapseindiappsdevelopment
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseindiappsdevelopment
 
SynapseIndia dotnet development platform overview
SynapseIndia  dotnet development platform overviewSynapseIndia  dotnet development platform overview
SynapseIndia dotnet development platform overviewSynapseindiappsdevelopment
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications developmentSynapseindiappsdevelopment
 
SynapseIndia dotnet website security development
SynapseIndia  dotnet website security developmentSynapseIndia  dotnet website security development
SynapseIndia dotnet website security developmentSynapseindiappsdevelopment
 
SynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseindiappsdevelopment
 
SynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseindiappsdevelopment
 
SynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseindiappsdevelopment
 
SynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseindiappsdevelopment
 
SynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseindiappsdevelopment
 

Más de Synapseindiappsdevelopment (20)

Synapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapse india elance top in demand in it skills
Synapse india elance top in demand in it skills
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture module
 
SynapseIndia dotnet module development part 1
SynapseIndia  dotnet module development part 1SynapseIndia  dotnet module development part 1
SynapseIndia dotnet module development part 1
 
SynapseIndia dotnet framework library
SynapseIndia  dotnet framework librarySynapseIndia  dotnet framework library
SynapseIndia dotnet framework library
 
SynapseIndia dotnet development platform overview
SynapseIndia  dotnet development platform overviewSynapseIndia  dotnet development platform overview
SynapseIndia dotnet development platform overview
 
SynapseIndia dotnet development framework
SynapseIndia  dotnet development frameworkSynapseIndia  dotnet development framework
SynapseIndia dotnet development framework
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications development
 
SynapseIndia dotnet website security development
SynapseIndia  dotnet website security developmentSynapseIndia  dotnet website security development
SynapseIndia dotnet website security development
 
SynapseIndia mobile build apps management
SynapseIndia mobile build apps managementSynapseIndia mobile build apps management
SynapseIndia mobile build apps management
 
SynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architecture
 
SynapseIndia java and .net development
SynapseIndia java and .net developmentSynapseIndia java and .net development
SynapseIndia java and .net development
 
SynapseIndia dotnet development panel control
SynapseIndia dotnet development panel controlSynapseIndia dotnet development panel control
SynapseIndia dotnet development panel control
 
SynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client library
 
SynapseIndia php web development
SynapseIndia php web developmentSynapseIndia php web development
SynapseIndia php web development
 
SynapseIndia mobile apps architecture
SynapseIndia mobile apps architectureSynapseIndia mobile apps architecture
SynapseIndia mobile apps architecture
 
SynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architecture
 
SynapseIndia mobile apps
SynapseIndia mobile appsSynapseIndia mobile apps
SynapseIndia mobile apps
 
SynapseIndia dotnet development
SynapseIndia dotnet developmentSynapseIndia dotnet development
SynapseIndia dotnet development
 
SynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseIndia dotnet client library Development
SynapseIndia dotnet client library Development
 
SynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically development
 

Último

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Último (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Synapse india basic php development part 2

  • 1. 1 44 You have been added to the 45 <span style = "color: blue"> 46 <strong> 47 <?php print( "$book " ); ?> 48 </strong> 49 </span> 50 mailing list. 51 </p> 52 <strong>The following information has been saved 53 in our database:</strong><br /> 54 55 <table border = "0" cellpadding = "0" cellspacing = "10"> 56 <tr> 57 <td bgcolor = "#ffffaa">Name </td> 58 <td bgcolor = "#ffffbb">Email</td> 59 <td bgcolor = "#ffffcc">Phone</td> 60 <td bgcolor = "#ffffdd">OS</td> 61 </tr> 62 63 <tr> 64 <?php 65 form.php (3 of 4)
  • 2. 2 form.php (4 of 4) 66 // print each form field’s value 67 print( "<td>$fname $lname</td> 68 <td>$email</td> 69 <td>$phone</td> 70 <td>$os</td>" ); 71 ?> 72 </tr> 73 </table> 74 75 <br /><br /><br /> 76 <div style = "font-size: 10pt; text-align: center"> 77 This is only a sample form. 78 You have not been added to a mailing list. 79 </div> 80 </body> 81 </html>
  • 3. 3 26.5 Form Processing and Business Logic Fig. 26.14 Obtaining user input through forms.
  • 4. 4 26.6 Verifying a Username and Password  Private website  Only accessible to certain individuals  Encrypt username and password data when sending, storing and retrieving for increased security  Implementing password checking  Login information stored in file • fopen function  Read, write, append modes  Store data using fputs • n newline character  Close files when done • fclose function
  • 5. 5 26.6 Verifying a Username and Password  Implementing password checking, cont.  Trim newline character • chop function  Split string into substrings given a certain delimiter • split function  If username/password match list, allow access
  • 6. 6 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 4 <!-- Fig. 26.15: password.html --> 5 <!-- XHTML form sent to password.php for verification --> 6 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 8 <head> 9 <title>Verifying a username and a password.</title> 10 11 <style type = "text/css"> 12 td { background-color: #DDDDDD } 13 </style> 14 </head> 15 16 <body style = "font-family: arial"> 17 <p style = "font-size: 13pt"> 18 Type in your username and password below. 19 <br /> 20 <span style = "color: #0000FF; font-size: 10pt; 21 font-weight: bold"> 22 Note that password will be sent as plain text 23 </span> 24 </p> 25 password.html (1 of 4)
  • 7. 7 26 <!-- post form data to password.php --> 27 <form action = "password.php" method = "post"> 28 <br /> 29 30 <table border = "0" cellspacing = "0" 31 style = "height: 90px; width: 123px; 32 font-size: 10pt" cellpadding = "0"> 33 34 <tr> 35 <td colspan = "3"> 36 <strong>Username:</strong> 37 </td> 38 </tr> 39 40 <tr> 41 <td colspan = "3"> 42 <input size = "40" name = "USERNAME" 43 style = "height: 22px; width: 115px" /> 44 </td> 45 </tr> 46 password.html (2 of 4) Form data is posted to password.php.
  • 8. 8 47 <tr> 48 <td colspan = "3"> 49 <strong>Password:</strong> 50 </td> 51 </tr> 52 53 <tr> 54 <td colspan = "3"> 55 <input size = "40" name = "PASSWORD" 56 style = "height: 22px; width: 115px" 57 type = "password" /> 58 <br/></td> 59 </tr> 60 61 <tr> 62 <td colspan = "1"> 63 <input type = "submit" name = "Enter" 64 value = "Enter" style = "height: 23px; 65 width: 47px" /> 66 </td> 67 <td colspan = "2"> 68 <input type = "submit" name = "NewUser" 69 value = "New User" 70 style = "height: 23px" /> 71 </td> password.html (3 of 4)
  • 9. 9 72 </tr> 73 </table> 74 </form> 75 </body> 76 </html> password.html (4 of 4)
  • 10. 10 26.6 Verifying a Username and Password Fig. 26.15 XHTML form for obtaining a username and password.
  • 11. 11 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 4 <!-- Fig. 26.16: password.php --> 5 <!-- Searching a database for usernames and passwords. --> 6 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 8 <head> 9 <?php 10 extract( $_POST ); 11 12 // check if user has left USERNAME or PASSWORD field blank 13 if ( !$USERNAME || !$PASSWORD ) { 14 fieldsBlank(); 15 die(); 16 } 17 18 // check if the New User button was clicked 19 if ( isset( $NewUser ) ) { 20 21 // open password.txt for writing using append mode 22 if ( !( $file = fopen( "password.txt", 23 "a" ) ) ) { 24 password.php (1 of 7) Variable names, when preceded by the logical negation operator (!), return true if they are empty or set to 0. This checks if a user has submitted a form without specifying a username or password. Function fieldsBlank is called if the user has submitted an incomplete form to notify the user that all form fields must be completed. Function isset tests whether the user has pressed the New User button, indicating that a new user must be added. To add a new user, we open the file password.txt in append mode and assign the file handle that is returned to variable $file.
  • 12. 12 25 // print error message and terminate script 26 // execution if file cannot be opened 27 print( "<title>Error</title></head><body> 28 Could not open password file 29 </body></html>" ); 30 die(); 31 } 32 33 // write username and password to file and 34 // call function userAdded 35 fputs( $file, "$USERNAME,$PASSWORDn" ); 36 userAdded( $USERNAME ); 37 } 38 else { 39 40 // if a new user is not being added, open file 41 // for reading 42 if ( !( $file = fopen( "password.txt", 43 "r" ) ) ) { 44 print( "<title>Error</title></head> 45 <body>Could not open password file 46 </body></html>" ); 47 die(); 48 } 49 password.php Print an error message and terminate sc(r2ip otf e 7x)ecution if the file cannot be opened. Function userAdded is called to print a message to the user to indicate that the username and password were added to the file. Function fputs writes the name and password to the text file..