Forms Overview, Query string, Submitting arrays, PHP & HTML, Input types, Redirecting the user Mario Peshev Technical Trainer Software.

Slides:



Advertisements
Similar presentations
Doncho Minkov Technical Trainer Telerik School Academy.
Advertisements

JavaScript Basics Course Introduction SoftUni Team Technical Trainers Software University
Software Quality Assurance QA Engineering, Testing, Bug Tracking, Test Automation Software University Technical Trainers SoftUni Team.
 Dimitar Ivanov Introduction to programming with microcontrollers.
AngularJS Routing Routes, Route Parameters, Templates, Location, Navigation SoftUni Team Technical Trainers Software University
AngularJS Services Built-in and Custom Services SoftUni Team Technical Trainers Software University
Software University Curriculum, Courses, Exams, Jobs SoftUni Team Technical Trainers Software University
PHP Basics Course Introduction SoftUni Team Technical Trainers Software University
Fundamentals SoftUni Welcome to Software University SoftUni Team Technical Trainers Software University
Project Tracking Tools Trello, Asana, Basecamp, GitHub Issue Tracker, TRAC SoftUni Team Technical Trainers Software University
AngularJS Directives Defining Custom Directives SoftUni Team Technical Trainers Software University
Software Testing Lifecycle Exit Criteria Evaluation, Continuous Integration Ivan Yonkov Technical Trainer Software University.
JavaScript Design Patterns Private Fields, Module, Revealing Module, Revealing Prototype, … Software University Technical Trainers SoftUni.
NoSQL Databases NoSQL Concepts SoftUni Team Technical Trainers Software University
Composer packages Installing and Using Composer, Packagist, Packaging your code Mario Peshev Technical Trainer Software University
Consuming REST Services from C# SoftUni Team Technical Trainers Software University
Database APIs and Wrappers
Entity Framework Performance SoftUni Team Technical Trainers Software University
Svetlin Nakov Technical Trainer Software University
Build Processes and Continuous Integration Automating Build Processes Software University Technical Trainers SoftUni Team.
Processing Redis with.NET How to Operate with Redis Databases SoftUni Team Technical Trainers Software University
Multidimensional Arrays, Sets, Dictionaries Processing Matrices, Multidimensional Arrays, Dictionaries, Sets SoftUni Team Technical Trainers Software University.
Project Tracking Tools Trello, Asana, Basecamp, GitHub Issue Tracker, TRAC Angel Georgiev Part-time Trainer Software University
Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University
JavaScript Basics Course Introduction Svetlin Nakov Technical Trainer Software University
CV Structure, Content, Layout, Formatting, Best Practices SoftUni Team Technical Trainers Software University
Templating, Routing, lodash Extending functionality using Collections SoftUni Team Technical Trainers Software University
ASP.NET MVC Architecture Layouts, Filters, Sections, Helpers, Partial Views, Areas… SoftUni Team Technical Trainers Software University
Controllers and Markup Controllers, $scope, Markup, Directives, Expressions, Binding, Filters, Validation SoftUni Team Technical Trainers Software University.
AMD and RequireJS Splitting JavaScript Code into Dependent Modules Software University Technical Trainers SoftUni Team.
Using SQL Connecting, Retrieving Data, Executing SQL Commands, … Svetlin Nakov Technical Trainer Software University
Asynchronous Web Services Writing Asynchronous Web Services SoftUni Team Technical Trainers Software University
Sessions and Cookies State Management, Cookies, Sessions, Hidden Fields SoftUni Team Technical Trainers Software University
Web Fundamentals (HTML and CSS) Course Introduction SoftUni Team Technical Trainers Software University
Controls, Widgets, Grid…
Jekyll Static Site Generator Template-Based Site Generation Svetlin Nakov Technical Trainer Software University
Web Fundamentals (HTML and CSS) Course Introduction Svetlin Nakov Technical Trainer Software University
HTML Forms Forms, Controls, Fields, Inputs, Submission, Validation SoftUni Team Technical Trainers Software University
JavaScript Modules and Patterns Private Fields, Module, Revealing Module, Revealing Prototype, … Software University Technical Trainers.
Web Development Tools Tools for Front-End Developers Writing HTML and CSS Code SoftUni Team Technical Trainers Software University
Web Fundamentals (HTML and CSS)
Responsive Design Design that Adapts to Different Devices SoftUni Team Technical Trainers Software University
Working with Forms in PHP HTTP GET / POST, Validation, Escaping, Input Types, Submitting Arrays, URL Redirecting, PHP Superglobals Svetlin Nakov Technical.
Processing JSON in.NET JSON, JSON.NET LINQ-to-JSON and JSON to XML SoftUni Team Technical Trainers Software University
Tables, Rows, Columns, Cells, Header, Footer, Colspan, Rowspan
CSS Transitions and Animations Animated HTML Elements SoftUni Team Technical Trainers Software University
Design Patterns: Structural Design Patterns General and reusable solutions to common problems in software design Software University
Bootstrap Front-End Framework for Responsive Web Sites Svetlin Nakov Technical Trainer Software University
Events Event Handling in JavaScript SoftUni Team Technical Trainers Software University
Mocking with Moq Tools for Easier Unit Testing SoftUni Team Technical Trainers Software University
Mocking with Moq Mocking tools for easier unit testing Svetlin Nakov Technical Trainer Software University
JavaScript Tools Tools for Writing / Editing / Debugging JavaScript Code Svetlin Nakov Technical Trainer Software University
ORM Basics Repository Pattern, Models, Entity Manager Ivan Yonkov Technical Trainer Software University
Test-Driven Development Learn the "Test First" Approach to Coding Svetlin Nakov Technical Trainer Software University
Sets, Dictionaries SoftUni Team Technical Trainers Software University
PHP Basics Course Introduction Svetlin Nakov Technical Trainer Software University
Functional Programming Data Aggregation and Nested Queries Ivan Yonkov Technical Trainer Software University
Doctrine The PHP ORM SoftUni Team Technical Trainers Software University
Creating Content Defining Topic, Creating Technical Training Materials SoftUni Team Technical Trainers Software University
Web Storage and Cookies Cookies, Local and Session Storage SoftUni Team Technical Trainers Software University
First Steps in PHP Creating Very Simple PHP Scripts SoftUni Team Technical Trainers Software University
Inheritance Class Hierarchies SoftUni Team Technical Trainers Software University
Stacks and Queues Processing Sequences of Elements SoftUni Team Technical Trainers Software University
Generics SoftUni Team Technical Trainers Software University
Introduction to MVC SoftUni Team Introduction to MVC
State Management Cookies, Sessions SoftUni Team State Management
Extending functionality using Collections
CSS Transitions and Animations
Software Quality Assurance
CSS Transitions and Animations
Presentation transcript:

Forms Overview, Query string, Submitting arrays, PHP & HTML, Input types, Redirecting the user Mario Peshev Technical Trainer Software University

Table of Contents 1.Quick overview 2.Query string 3.Submitting arrays 4.Combining HTML & PHP 5.Checkboxes 6.Hidden Fields 7.Other input types 2

Table of Contents (2) 8.Specific input attributes 9.Tab Index 10. Redirecting the user 3

Quick overview

 Forms are used to work with user input  Request method can be POST or GET  Input is stored in $_POST or $_GET arrays

Query String

What is Query string?  A query string is a part of a URL. Specifically, the part of a URL following a question mark (?)  Commonly used in searches and dynamic pages  Stored in $_SERVER['QUERY_STRING']

Creating a Query string  Most common way to do it is by using a FORM with GET method  You can also use scripts to add to the query string or simply write your links with the query strings in the href attribute

Query string Live Demo

Submitting arrays

 In order for an input to be treated as an array – you must put brackets “[]” in the name attribute: Mario Svetlin Teodor

Submitting arrays (2)  After the form is sent you can access your elements like you are acessing an array <?php foreach( $_POST['people'] as $person ) { echo $person. ' '; } ?>

Submitting Arrays Live Demo

Combining HTML and PHP

<?php //guessing script implementation... $message =...; ?>...  You can open PHP tags anywhere in HTML code

Combining HTML and PHP <?php echo ' Name: '; ?>  You can also echo the HTML

Checkboxes

Checkoxes  Checkboxes are created by setting an input with type “checkbox”  A checkbox is only submitted if it's actually checked

Checkboxes Live Demo

Hidden fields

<input type="hidden" name=“hiddenName" value=" "/>  Created by setting the type of input to hidden  Not visible to the user

Hidden fields Live Demo

Other input types

 password – doesn’t visualise the text written in the input  – some mobile browsers change the on-screen keyboard Has some in-build validations  radio - radio buttons are used to select ONLY one of a limited choices. In order for radio buttons to work properly – they must have the same “name” attribute

Other input types (2)  date – used to pick a date (Doesn’t work on Firefox and IE.)  datetime – used to pick date and time (Works only Safari and Opera)  time – used to pick time (Doesn’t work on Firefox and IE.)

Other input types (3)  number – used to pick a number  range – creates a slider that allows you to pick a value from a previously set range  color – creates a palette that allows you to pick a color

Other input types Live Demo

Specific input attributes

 autocomplete – browser stores previously typed values and shows them the next time  autofocus – the field becomes focused on page load  required – the field becomes required and the form can not be send without filling/selecting it first

Tab index

Tab Index  The tabindex attribute controls the order in which form fields and links are focused when repeatedly pressing the TAB key  tabindex="0" (zero) – means "natural" order  Elements with smaller tabindex are iterated before elements with bigger tabindex

Tab index Live Demo

Redirecting the user

header(‘Location:  Done by using the HTTP Location header $url = ‘ header(‘Location: ‘. $url);  You can also use a variable to keep the URL

Redirecting the user Live Demo

36 Summary  You must put [] in input’s name attribute in order to submit an array of information  You can easily combine PHP and HTML  Checkboxes are sent only if checked  Hidden fields are not visible to the user  The HTTP Location Header redirects the user

? ? ? ? ? ? ? ? ? PHP & MySQL

License  This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" licenseCreative Commons Attribution- NonCommercial-ShareAlike 4.0 International  Attribution: this work may contain portions from  "PHP Manual" by The PHP Group under CC-BY licensePHP ManualCC-BY  "PHP and MySQL Web Development" course by Telerik Academy under CC-BY-NC-SA licensePHP and MySQL Web DevelopmentCC-BY-NC-SA 38

Free Software University  Software University Foundation – softuni.orgsoftuni.org  Software University – High-Quality Education, Profession and Job for Software Developers  softuni.bg softuni.bg  Software Facebook  facebook.com/SoftwareUniversity facebook.com/SoftwareUniversity  Software YouTube  youtube.com/SoftwareUniversity youtube.com/SoftwareUniversity  Software University Forums – forum.softuni.bgforum.softuni.bg