php validation basics

15
PHP Validation Basics

Upload: prodigyview

Post on 03-Dec-2014

1.475 views

Category:

Technology


0 download

DESCRIPTION

Learn how to use the native validation methods in ProdigyView. Includes validating mime types of files.

TRANSCRIPT

Page 1: PHP Validation Basics

PHP Validation Basics

Page 2: PHP Validation Basics

Overview

Objective

Learn the native features of validation in ProdigyView.

Requirements

Understanding of mime types

Basic knowledge of the file manager

Estimated Time

8 Minutes

www.prodigyview.com

Page 3: PHP Validation Basics

Follow Along With Code Example

1. Download a copy of the example code at www.prodigyview.com/source.

2. Install the system in an environment you feel comfortable testing in.

3.Proceed to examples/util/Validation.php

Page 4: PHP Validation Basics

ValidationValidation is process of the checking data against a set of parameters. If the parameters match, a true is returned, otherwise false.

Validation can be used internally but it most commonly used with checking user input.

In this tutorial, we will be briefly introducing you to common validation used in PHP and its native implementation in ProdigyView.

www.prodigyview.com

Page 5: PHP Validation Basics

Integer Validation

Integer validation is a good point to start. An example usage is many SQL databases use auto incremented ids which are integers. You may want to verify that the id they are going to use to update a record is an integer.

Page 6: PHP Validation Basics

Double Validation

Double validation will cover validation for types double, floats, longs, and anything else that contains a period and a number. Passing an integer to double validation will fail.

www.prodigyview.com

Page 7: PHP Validation Basics

Email ValidationA common validation with web applications is the email. You want the user who is registering for the application to at least enter a real email.

Page 8: PHP Validation Basics

Audio File TypeOn your way to making the next Pandora? In that case you want audio file mime type validation. While the example below checks all audio mime types, it can be further specified to check only one type.

Supported validation formats: mp3, wav, ra, oga, midi, aif

Page 9: PHP Validation Basics

Video File Types

Similar to the audio file type, video mime types can also be validated. The example below is also all inclusive but video mime types can be checked individually.

Supported Validation Formats: ogv, mpeg, wmv, mp4, flv, quicktime, mov, mxu , avi, real video, asf, webm

Page 10: PHP Validation Basics

Image File TypesCheck image file types before deciding to accept them. Below is the method checking all images types but they can also be checked individually.

Supported Validation Formats: png, gif, jpeg, ief, bmp, tiff

Page 11: PHP Validation Basics

Compress Files

Compressed files include zip, tar and gtar. Validate that the file is actually a compressed file and does not merely have the extension of a compressed file.

www.prodigyview.com

Page 12: PHP Validation Basics

Microsoft Files

Microsoft files include Word, Excel and Powerpoint. Divided further, we have .doc, docx and so forth, each which has different mime-types. In ProdigyView, we can validate against any of those Microsoft file types.

www.prodigyview.com

Page 13: PHP Validation Basics

Other ValidationThis tutorial only showed a brief overview native validation in ProdigyView. There are many more validation type available, read through the api.

There is also the ability to add custom validation to PVValidator in the tutorial on ‘Custom Validation’.

Other Native Validation Examples

isValidUrl

isActiveUrl

isPdf

isID

isTextFile

IsCSSFile

www.prodigyview.com

Page 14: PHP Validation Basics

Challenge!

This is optional challenge that will help you better understand Validation and File Management.

1. Located a video file on your computer/server.

2. With PVFileManager, retrieve the mime type of the video file

3. Check against the file type specifically. Example, if the video file is an avi, validate ONLY against avi files.

4. If the validation passed, copy the file to another location using PVFileManager.

www.prodigyview.com

Page 15: PHP Validation Basics

API ReferenceFor a better understanding of Validation in ProdigyView, visit the api by clicking on the link below.

PVValidator

www.prodigyview.com

More Tutorials

For more tutorials, please visit:

http://www.prodigyview.com/tutorials