File: example.php

Recommend this page to a friend!
  Classes of Troy  >  PHP Data Validation  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example code
Class: PHP Data Validation
Validate and filter different types of data
Author: By
Last change:
Date: 12 years ago
Size: 1,250 bytes
 

 

Contents

Class file image Download
<?php
$db_user
= "";
$db_pass = "";
$db_serv = "";
$db_name = "";
include(
"../database/database.class.php");
$db = new Database($db_user,$db_pass,$db_serv,true);
if(!
$db){die($db->getErrorMessage());}

include(
"validation.class.php");
$validation = new Validation;

echo
"SELECT * FROM users WHERE user='".$validation->db_prep($validation->database_input)."'";
echo
"<br>";

if(
$validation->email($validation->email)) echo "valid email";
else echo
"not valid email";
echo
"<br>";

if(
$validation->phone($validation->phone)) echo "valid phone";
else echo
"not valid phone";
echo
"<br>";

if(
$validation->url($validation->url)) echo "valid url";
else echo
"not valid url";
echo
"<br>";
?>
<form action="test.php" method="post">
    <p>database input: <input type="text" name="database_input" id="database_input" value="<?=$validation->database_input;?>" /></p>
    <p>email: <input type="text" name="email" id="email" value="<?=$validation->email;?>" /></p>
    <p>phone: <input type="text" name="phone" id="phone" value="<?=$validation->phone;?>" /></p>
    <p>url: <input type="text" name="url" id="url" value="<?=$validation->url;?>" /></p>
    <p><input type="submit" name="test" id="dtest" value="Test" /></p>
</form>


For more information send a message to info at phpclasses dot org.