SlideShare a Scribd company logo
Forms/PHP
BITM 3730
Developing Web Applications
10/25
Basic HTML Form
• Boring
• Limited
• Hard to Store info
Reminder from HTML Lesson
• <form>…</form> - defines a form
• <input type…/> - defines a form input
• button
checkbox
file
hidden
image
password
radio
reset
submit
text
Inputs - HTML
<input type="text"> Displays a single-line text input field
<input type="radio"> Displays a radio button (for selecting one of
many choices)
<input type="checkbox"> Displays a checkbox (for selecting zero or
more of many choices)
<input type="submit"> Displays a submit button (for submitting the
form)
<input type="button"> Displays a clickable button
HTML Example
• <html>
• <body>
• <h2>HTML Form</h2>
• <form action="/action_page.php">
• <label for="fname">First name:</label><br>
• <input type="text" id="fname" name="fname" value="John"><br>
• <label for="lname">Last name:</label><br>
• <input type="text" id="lname" name="lname" value="Doe"><br><br>
• <input type="submit" value="Submit">
• </form>
• </body>
• </html>
Visual
Only two inputs
Both inputs are text
<form action="/action_page.php">
• This does all the work of sending the information
HTML with no PHP
• <html>
• <body>
• <h2>HTML Form</h2>
• <form>
• <label for="fname">First name:</label><br>
• <input type="text" id="fname" name="fname" value="John"><br>
• <label for="lname">Last name:</label><br>
• <input type="text" id="lname" name="lname" value="Doe"><br><br>
• <input type="submit" value="Submit">
• </form>
• </body>
• </html>
Does not send the input
anywhere
Why Won’t This Work?
• <form action="/action_page.php">
• <label for="fname">First name:</label><br>
• <input type="text" id="fname" value="John"><br><br>
• <input type="text" id="fname" name="fname" value="John"><br>
• <input type="submit" value="Submit">
• </form>
Missing name="fname"
Radio Buttons
• <form>
• <input type="radio" id="html" name="fav_language" value="HTML">
• <label for="html">HTML</label><br>
• <input type="radio" id="css" name="fav_language" value="CSS">
• <label for="css">CSS</label><br>
• <input type="radio" id="javascript" name="fav_language" value="JavaScript">
• <label for="javascript">JavaScript</label>
• </form>
Check Boxes
• <form>
• <input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
• <label for="vehicle1"> I have a bike</label><br>
• <input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
• <label for="vehicle2"> I have a car</label><br>
• <input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
• <label for="vehicle3"> I have a boat</label>
• </form>
All Input Types
• <input type="button">
• <input type="checkbox">
• <input type="color">
• <input type="date">
• <input type="datetime-local">
• <input type="email">
• <input type="file">
• <input type="hidden">
• <input type="image">
• <input type="month">
• <input type="number">
• <input type="password">
• <input type="radio">
• <input type="range">
• <input type="reset">
• <input type="search">
• <input type="submit">
• <input type="tel">
• <input type="text">
• <input type="time">
• <input type="url">
• <input type="week">
Understanding PHP
• A PHP script can be placed anywhere in the document.
• A PHP script starts with <?php and ends with ?>:
• <?php
• // PHP code goes here
• ?>
• The default file extension for PHP files is ".php".
• A PHP file normally contains HTML tags, and some PHP scripting code.
Using PHP – HTML Code
• <html>
• <body>
• <form action="welcome_get.php" method="get">
• Name: <input type="text" name="name"><br>
• E-mail: <input type="text" name="email"><br>
• <input type="submit">
• </form>
• </body>
• </html>
welcome_get.php Code
• <html>
• <body>
• Welcome <?php echo $_GET["name"]; ?><br>
• Your email address is: <?php echo $_GET["email"]; ?>
• </body>
• </html>
Visual
Once submitted, displays
Using PHP to Upload Files - HTML
• <html>
• <body>
• <form action="upload.php" method="post" enctype="multipart/form-data">
• Select image to upload:
• <input type="file" name="fileToUpload" id="fileToUpload">
• <input type="submit" value="Upload Image" name="submit">
• </form>
• </body>
• </html>
upload.php
• <?php
• $target_dir = "uploads/";
• $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
• $uploadOk = 1;
• $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
• // Check if image file is a actual image or fake image
• if(isset($_POST["submit"])) {
• $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
• if($check !== false) {
• echo "File is an image - " . $check["mime"] . ".";
• $uploadOk = 1;
• } else {
• echo "File is not an image.";
• $uploadOk = 0;
• }
• }
upload.php
• // Check if file already exists
• if (file_exists($target_file)) {
• echo "Sorry, file already exists.";
• $uploadOk = 0;
• }
• // Check file size
• if ($_FILES["fileToUpload"]["size"] > 500000) {
• echo "Sorry, your file is too large.";
• $uploadOk = 0;
• }
• // Allow certain file formats
• if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
• && $imageFileType != "gif" ) {
• echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
• $uploadOk = 0;
• }
upload.php
• // Check if $uploadOk is set to 0 by an error
• if ($uploadOk == 0) {
• echo "Sorry, your file was not uploaded.";
• // if everything is ok, try to upload file
• } else {
• if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
• echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
• } else {
• echo "Sorry, there was an error uploading your file.";
• }
• }
• ?>
What is the PHP Code Doing?
• PHP script explained:
• $target_dir = "uploads/" - specifies the directory where the file is going to be
placed
• $target_file specifies the path of the file to be uploaded
• $uploadOk=1 is not used yet (will be used later)
• $imageFileType holds the file extension of the file (in lower case)
• Next, check if the image file is an actual image or a fake image
PHP Open and Read
• <?php
• $myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!");
• echo fread($myfile,filesize("webdictionary.txt"));
• fclose($myfile);
• ?>
PHP Create and Write
• <?php
• $myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
• $txt = "John Doen";
• fwrite($myfile, $txt);
• $txt = "Jane Doen";
• fwrite($myfile, $txt);
• fclose($myfile);
• ?>
Homework
Assignment 7:
Using PHP, JavaScript and/or HTML create a Contact form which will accept Name, Email, and
Comment as inputs. The Submit button can either return the input or provide an external webpage noting
your input has been emailed.
HTML
• <html>
• <body>
• <form action="welcome.php" method="post">
• Name: <input type="text" name="name"><br>
• E-mail: <input type="text" name="email"><br>
• Comment: <input type="text" name="comment"><br>
• <input type="submit">
• </form>
• </body>
• </html>
Have to edit welcome.php
• <html>
• <body>
• Welcome <?php echo $_POST["name"]; ?><br>
• Your email address is: <?php echo $_POST["email"]; ?>
• Your comment was: <?php echo $_POST[“comment”]; ?>
• </body>
• </html>
To Send via Email
• <?php
• $from = "matt.marino@shu.edu";
• $to = "dspace-community@googlegroups.com";
• $message = "Unsubscribe";
• $info = "Unsubscribe";
• $check = mail($to, "Unsubscribe",
• $message, "From:matt.marino@shu.edu");
• if ($check != true) { echo "Sorry... Error Sending E-Mail. E-Mail NOT Sent.";}
• else { echo "Thank You. Your E-Mail Has Been Sent... We Will Get Back To You Shortly...";}
Create a file mailtest.php
and upload to your courses
web space
Change the to
To your email address, so you
get the inputs
HTML for Email
• <html>
• <body>
• <form action=“mailtest.php" method="post">
• Name: <input type="text" name="name"><br>
• E-mail: <input type="text" name="email"><br>
• Comment: <input type="text" name="comment"><br>
• <input type="submit">
• </form>
• </body>
• </html>
PHP files must be live on a web server to
work properly

More Related Content

Similar to BITM3730 10-25.pptx

PHP 1
PHP 1PHP 1
Web весна 2013 лекция 7
Web весна 2013 лекция 7Web весна 2013 лекция 7
Web весна 2013 лекция 7
Technopark
 
Web осень 2012 лекция 7
Web осень 2012 лекция 7Web осень 2012 лекция 7
Web осень 2012 лекция 7
Technopark
 
Introduction to web development - HTML 5
Introduction to web development - HTML 5Introduction to web development - HTML 5
Introduction to web development - HTML 5
Ayoub Ghozzi
 
Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5
Mohd Harris Ahmad Jaal
 
lecture 11.pptx
lecture 11.pptxlecture 11.pptx
lecture 11.pptx
ITNet
 
WT HTML
WT HTMLWT HTML
WT HTML
Mohan186867
 
Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2
Gheyath M. Othman
 
Secure PHP Coding - Part 1
Secure PHP Coding - Part 1Secure PHP Coding - Part 1
Secure PHP Coding - Part 1
Vinoth Kumar
 
HTML FORMS.pptx
HTML FORMS.pptxHTML FORMS.pptx
HTML FORMS.pptx
Sierranaijamusic
 
Web application, cookies and sessions
Web application, cookies and sessionsWeb application, cookies and sessions
Web application, cookies and sessions
hamsa nandhini
 
htmlcss.pdf
htmlcss.pdfhtmlcss.pdf
htmlcss.pdf
ElieMambou1
 
What you need to know bout html5
What you need to know bout html5What you need to know bout html5
What you need to know bout html5
Kevin DeRudder
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
COMMON Europe
 
Getting Information through HTML Forms
Getting Information through HTML FormsGetting Information through HTML Forms
Getting Information through HTML Forms
Mike Crabb
 
FormL13.pptx
FormL13.pptxFormL13.pptx
FormL13.pptx
serd4
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
Yusuke Wada
 
Html5 101
Html5 101Html5 101
Html5 101
Mouafa Ahmed
 
5.1 html lec 5
5.1 html lec 55.1 html lec 5
5.1 html lec 5
IoT Code Lab
 
Php Tutorial
Php TutorialPhp Tutorial

Similar to BITM3730 10-25.pptx (20)

PHP 1
PHP 1PHP 1
PHP 1
 
Web весна 2013 лекция 7
Web весна 2013 лекция 7Web весна 2013 лекция 7
Web весна 2013 лекция 7
 
Web осень 2012 лекция 7
Web осень 2012 лекция 7Web осень 2012 лекция 7
Web осень 2012 лекция 7
 
Introduction to web development - HTML 5
Introduction to web development - HTML 5Introduction to web development - HTML 5
Introduction to web development - HTML 5
 
Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5
 
lecture 11.pptx
lecture 11.pptxlecture 11.pptx
lecture 11.pptx
 
WT HTML
WT HTMLWT HTML
WT HTML
 
Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2
 
Secure PHP Coding - Part 1
Secure PHP Coding - Part 1Secure PHP Coding - Part 1
Secure PHP Coding - Part 1
 
HTML FORMS.pptx
HTML FORMS.pptxHTML FORMS.pptx
HTML FORMS.pptx
 
Web application, cookies and sessions
Web application, cookies and sessionsWeb application, cookies and sessions
Web application, cookies and sessions
 
htmlcss.pdf
htmlcss.pdfhtmlcss.pdf
htmlcss.pdf
 
What you need to know bout html5
What you need to know bout html5What you need to know bout html5
What you need to know bout html5
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
 
Getting Information through HTML Forms
Getting Information through HTML FormsGetting Information through HTML Forms
Getting Information through HTML Forms
 
FormL13.pptx
FormL13.pptxFormL13.pptx
FormL13.pptx
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Html5 101
Html5 101Html5 101
Html5 101
 
5.1 html lec 5
5.1 html lec 55.1 html lec 5
5.1 html lec 5
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 

More from MattMarino13

1-22-24 INFO 2106.pptx
1-22-24 INFO 2106.pptx1-22-24 INFO 2106.pptx
1-22-24 INFO 2106.pptx
MattMarino13
 
1-24-24 INFO 3205.pptx
1-24-24 INFO 3205.pptx1-24-24 INFO 3205.pptx
1-24-24 INFO 3205.pptx
MattMarino13
 
BITM3730 11-14.pptx
BITM3730 11-14.pptxBITM3730 11-14.pptx
BITM3730 11-14.pptx
MattMarino13
 
01_Felke-Morris_Lecture_ppt_ch01.pptx
01_Felke-Morris_Lecture_ppt_ch01.pptx01_Felke-Morris_Lecture_ppt_ch01.pptx
01_Felke-Morris_Lecture_ppt_ch01.pptx
MattMarino13
 
02slide_accessible.pptx
02slide_accessible.pptx02slide_accessible.pptx
02slide_accessible.pptx
MattMarino13
 
Hoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptxHoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptx
MattMarino13
 
AndroidHTP3_AppA.pptx
AndroidHTP3_AppA.pptxAndroidHTP3_AppA.pptx
AndroidHTP3_AppA.pptx
MattMarino13
 
9780357132302_Langley11e_ch1_LEAP.pptx
9780357132302_Langley11e_ch1_LEAP.pptx9780357132302_Langley11e_ch1_LEAP.pptx
9780357132302_Langley11e_ch1_LEAP.pptx
MattMarino13
 
krajewski_om12 _01.pptx
krajewski_om12 _01.pptxkrajewski_om12 _01.pptx
krajewski_om12 _01.pptx
MattMarino13
 
CapsimOpsIntroPPT.Marino.pptx
CapsimOpsIntroPPT.Marino.pptxCapsimOpsIntroPPT.Marino.pptx
CapsimOpsIntroPPT.Marino.pptx
MattMarino13
 
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptxProject Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
MattMarino13
 
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptxProject Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
MattMarino13
 
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
MattMarino13
 
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
MattMarino13
 
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
MattMarino13
 
1-23-19 Agenda.pptx
1-23-19 Agenda.pptx1-23-19 Agenda.pptx
1-23-19 Agenda.pptx
MattMarino13
 
EDF 8289 Marino PPT.pptx
EDF 8289 Marino PPT.pptxEDF 8289 Marino PPT.pptx
EDF 8289 Marino PPT.pptx
MattMarino13
 
Agenda January 20th 2016.pptx
Agenda January 20th 2016.pptxAgenda January 20th 2016.pptx
Agenda January 20th 2016.pptx
MattMarino13
 
BITM3730 8-29.pptx
BITM3730 8-29.pptxBITM3730 8-29.pptx
BITM3730 8-29.pptx
MattMarino13
 
BITM3730 8-30.pptx
BITM3730 8-30.pptxBITM3730 8-30.pptx
BITM3730 8-30.pptx
MattMarino13
 

More from MattMarino13 (20)

1-22-24 INFO 2106.pptx
1-22-24 INFO 2106.pptx1-22-24 INFO 2106.pptx
1-22-24 INFO 2106.pptx
 
1-24-24 INFO 3205.pptx
1-24-24 INFO 3205.pptx1-24-24 INFO 3205.pptx
1-24-24 INFO 3205.pptx
 
BITM3730 11-14.pptx
BITM3730 11-14.pptxBITM3730 11-14.pptx
BITM3730 11-14.pptx
 
01_Felke-Morris_Lecture_ppt_ch01.pptx
01_Felke-Morris_Lecture_ppt_ch01.pptx01_Felke-Morris_Lecture_ppt_ch01.pptx
01_Felke-Morris_Lecture_ppt_ch01.pptx
 
02slide_accessible.pptx
02slide_accessible.pptx02slide_accessible.pptx
02slide_accessible.pptx
 
Hoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptxHoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptx
 
AndroidHTP3_AppA.pptx
AndroidHTP3_AppA.pptxAndroidHTP3_AppA.pptx
AndroidHTP3_AppA.pptx
 
9780357132302_Langley11e_ch1_LEAP.pptx
9780357132302_Langley11e_ch1_LEAP.pptx9780357132302_Langley11e_ch1_LEAP.pptx
9780357132302_Langley11e_ch1_LEAP.pptx
 
krajewski_om12 _01.pptx
krajewski_om12 _01.pptxkrajewski_om12 _01.pptx
krajewski_om12 _01.pptx
 
CapsimOpsIntroPPT.Marino.pptx
CapsimOpsIntroPPT.Marino.pptxCapsimOpsIntroPPT.Marino.pptx
CapsimOpsIntroPPT.Marino.pptx
 
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptxProject Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
 
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptxProject Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
 
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
 
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
 
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
 
1-23-19 Agenda.pptx
1-23-19 Agenda.pptx1-23-19 Agenda.pptx
1-23-19 Agenda.pptx
 
EDF 8289 Marino PPT.pptx
EDF 8289 Marino PPT.pptxEDF 8289 Marino PPT.pptx
EDF 8289 Marino PPT.pptx
 
Agenda January 20th 2016.pptx
Agenda January 20th 2016.pptxAgenda January 20th 2016.pptx
Agenda January 20th 2016.pptx
 
BITM3730 8-29.pptx
BITM3730 8-29.pptxBITM3730 8-29.pptx
BITM3730 8-29.pptx
 
BITM3730 8-30.pptx
BITM3730 8-30.pptxBITM3730 8-30.pptx
BITM3730 8-30.pptx
 

Recently uploaded

Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
Mohammad Al-Dhahabi
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
Celine George
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
khuleseema60
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
JomonJoseph58
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 

Recently uploaded (20)

Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 

BITM3730 10-25.pptx

  • 2. Basic HTML Form • Boring • Limited • Hard to Store info
  • 3. Reminder from HTML Lesson • <form>…</form> - defines a form • <input type…/> - defines a form input • button checkbox file hidden image password radio reset submit text
  • 4. Inputs - HTML <input type="text"> Displays a single-line text input field <input type="radio"> Displays a radio button (for selecting one of many choices) <input type="checkbox"> Displays a checkbox (for selecting zero or more of many choices) <input type="submit"> Displays a submit button (for submitting the form) <input type="button"> Displays a clickable button
  • 5. HTML Example • <html> • <body> • <h2>HTML Form</h2> • <form action="/action_page.php"> • <label for="fname">First name:</label><br> • <input type="text" id="fname" name="fname" value="John"><br> • <label for="lname">Last name:</label><br> • <input type="text" id="lname" name="lname" value="Doe"><br><br> • <input type="submit" value="Submit"> • </form> • </body> • </html>
  • 6. Visual Only two inputs Both inputs are text
  • 7. <form action="/action_page.php"> • This does all the work of sending the information
  • 8. HTML with no PHP • <html> • <body> • <h2>HTML Form</h2> • <form> • <label for="fname">First name:</label><br> • <input type="text" id="fname" name="fname" value="John"><br> • <label for="lname">Last name:</label><br> • <input type="text" id="lname" name="lname" value="Doe"><br><br> • <input type="submit" value="Submit"> • </form> • </body> • </html> Does not send the input anywhere
  • 9. Why Won’t This Work? • <form action="/action_page.php"> • <label for="fname">First name:</label><br> • <input type="text" id="fname" value="John"><br><br> • <input type="text" id="fname" name="fname" value="John"><br> • <input type="submit" value="Submit"> • </form> Missing name="fname"
  • 10. Radio Buttons • <form> • <input type="radio" id="html" name="fav_language" value="HTML"> • <label for="html">HTML</label><br> • <input type="radio" id="css" name="fav_language" value="CSS"> • <label for="css">CSS</label><br> • <input type="radio" id="javascript" name="fav_language" value="JavaScript"> • <label for="javascript">JavaScript</label> • </form>
  • 11. Check Boxes • <form> • <input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"> • <label for="vehicle1"> I have a bike</label><br> • <input type="checkbox" id="vehicle2" name="vehicle2" value="Car"> • <label for="vehicle2"> I have a car</label><br> • <input type="checkbox" id="vehicle3" name="vehicle3" value="Boat"> • <label for="vehicle3"> I have a boat</label> • </form>
  • 12. All Input Types • <input type="button"> • <input type="checkbox"> • <input type="color"> • <input type="date"> • <input type="datetime-local"> • <input type="email"> • <input type="file"> • <input type="hidden"> • <input type="image"> • <input type="month"> • <input type="number"> • <input type="password"> • <input type="radio"> • <input type="range"> • <input type="reset"> • <input type="search"> • <input type="submit"> • <input type="tel"> • <input type="text"> • <input type="time"> • <input type="url"> • <input type="week">
  • 13. Understanding PHP • A PHP script can be placed anywhere in the document. • A PHP script starts with <?php and ends with ?>: • <?php • // PHP code goes here • ?> • The default file extension for PHP files is ".php". • A PHP file normally contains HTML tags, and some PHP scripting code.
  • 14. Using PHP – HTML Code • <html> • <body> • <form action="welcome_get.php" method="get"> • Name: <input type="text" name="name"><br> • E-mail: <input type="text" name="email"><br> • <input type="submit"> • </form> • </body> • </html>
  • 15. welcome_get.php Code • <html> • <body> • Welcome <?php echo $_GET["name"]; ?><br> • Your email address is: <?php echo $_GET["email"]; ?> • </body> • </html>
  • 17. Using PHP to Upload Files - HTML • <html> • <body> • <form action="upload.php" method="post" enctype="multipart/form-data"> • Select image to upload: • <input type="file" name="fileToUpload" id="fileToUpload"> • <input type="submit" value="Upload Image" name="submit"> • </form> • </body> • </html>
  • 18. upload.php • <?php • $target_dir = "uploads/"; • $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); • $uploadOk = 1; • $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); • // Check if image file is a actual image or fake image • if(isset($_POST["submit"])) { • $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); • if($check !== false) { • echo "File is an image - " . $check["mime"] . "."; • $uploadOk = 1; • } else { • echo "File is not an image."; • $uploadOk = 0; • } • }
  • 19. upload.php • // Check if file already exists • if (file_exists($target_file)) { • echo "Sorry, file already exists."; • $uploadOk = 0; • } • // Check file size • if ($_FILES["fileToUpload"]["size"] > 500000) { • echo "Sorry, your file is too large."; • $uploadOk = 0; • } • // Allow certain file formats • if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" • && $imageFileType != "gif" ) { • echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; • $uploadOk = 0; • }
  • 20. upload.php • // Check if $uploadOk is set to 0 by an error • if ($uploadOk == 0) { • echo "Sorry, your file was not uploaded."; • // if everything is ok, try to upload file • } else { • if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { • echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded."; • } else { • echo "Sorry, there was an error uploading your file."; • } • } • ?>
  • 21. What is the PHP Code Doing? • PHP script explained: • $target_dir = "uploads/" - specifies the directory where the file is going to be placed • $target_file specifies the path of the file to be uploaded • $uploadOk=1 is not used yet (will be used later) • $imageFileType holds the file extension of the file (in lower case) • Next, check if the image file is an actual image or a fake image
  • 22. PHP Open and Read • <?php • $myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!"); • echo fread($myfile,filesize("webdictionary.txt")); • fclose($myfile); • ?>
  • 23. PHP Create and Write • <?php • $myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); • $txt = "John Doen"; • fwrite($myfile, $txt); • $txt = "Jane Doen"; • fwrite($myfile, $txt); • fclose($myfile); • ?>
  • 24. Homework Assignment 7: Using PHP, JavaScript and/or HTML create a Contact form which will accept Name, Email, and Comment as inputs. The Submit button can either return the input or provide an external webpage noting your input has been emailed.
  • 25. HTML • <html> • <body> • <form action="welcome.php" method="post"> • Name: <input type="text" name="name"><br> • E-mail: <input type="text" name="email"><br> • Comment: <input type="text" name="comment"><br> • <input type="submit"> • </form> • </body> • </html>
  • 26. Have to edit welcome.php • <html> • <body> • Welcome <?php echo $_POST["name"]; ?><br> • Your email address is: <?php echo $_POST["email"]; ?> • Your comment was: <?php echo $_POST[“comment”]; ?> • </body> • </html>
  • 27. To Send via Email • <?php • $from = "matt.marino@shu.edu"; • $to = "dspace-community@googlegroups.com"; • $message = "Unsubscribe"; • $info = "Unsubscribe"; • $check = mail($to, "Unsubscribe", • $message, "From:matt.marino@shu.edu"); • if ($check != true) { echo "Sorry... Error Sending E-Mail. E-Mail NOT Sent.";} • else { echo "Thank You. Your E-Mail Has Been Sent... We Will Get Back To You Shortly...";} Create a file mailtest.php and upload to your courses web space Change the to To your email address, so you get the inputs
  • 28. HTML for Email • <html> • <body> • <form action=“mailtest.php" method="post"> • Name: <input type="text" name="name"><br> • E-mail: <input type="text" name="email"><br> • Comment: <input type="text" name="comment"><br> • <input type="submit"> • </form> • </body> • </html> PHP files must be live on a web server to work properly