PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Tomek Topa   My Form   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example.php
Class: My Form
Generate and validate Web forms
Author: By
Last change:
Date: 19 years ago
Size: 2,982 bytes
 

Contents

Class file image Download
<html>
<head>
    <title>example</sample>
    <link rel="stylesheet" href="./sheet.css" type="text/css" />
</head>

<body>
<?php

require "./class.my_form.php";

function
_send () {

    if (!
eregi('@', $_POST["email"], $regs)) {
       
$_errors[] = array("_type" => "_item", "_item" => "email", "_value" => "Invalid E-mail");
    }
   
    if (
count($_errors) == 0 ) {
        echo
"<B>".$_POST["name"]."<br />Registration complete</b>";
    }


    return
$_errors;
}


require
"./functions_form.php";



$_form = new _my_form();
$_form -> _create_form('Sample form #1', '_send', $_errors);
$_form -> _add_element( "Your name:", "name", "text", "", "", "", ' ');
$_form -> _add_element( "Your E-mail:", "email", "text", "", "", "", ' ');
$_form -> _add_element( "Your sex:", "sex", "radio", array('values' => array('m' => 'male', 'f'=>'female'), 'select' => ''), "", "", ' ');
$_form -> _add_element( "Your favourite music:", "music", "checkbox", array('values' => array('techno' => 'techno', 'pop'=> 'Pop', 'randb' => 'R&B'), 'select' => array('techno', 'pop')), "", "", ' ');
$_form -> _add_element( "Your country", "country", "select", array('values' => array('pl' => 'Poland', 'uk'=>'United Kingdom'), 'select' => 'pl'), "", "", ' ');
$_form -> _add_element( "About you", "about", "textarea", "", "", "", ' ');
$_form -> _add_element( "Iformation", "", "html", "If you want register please click Dalej", "", "", ' ');
$_form -> _add_rule( array('name', 'about') );
echo
$_form -> _display_form();



?>


<pre class="code">
require "./class.my_form.php";

function _send () {

    if (!eregi('@', $_POST["email"], $regs)) {
        $_errors[] = array("_type" => "_item", "_item" => "email", "_value" => "Invalid E-mail");
    }

    if ( count($_errors) == 0 ) {
        echo"<B>".$_POST["name"]."<br />Registration complete</b>";
    }


    return $_errors;
}

require "./functions_form.php";



$_form = new _my_form();
$_form -> _create_form('Sample form #1', '_send', $_errors);
$_form -> _add_element( "Your name:", "name", "text", "", "", "", ' ');
$_form -> _add_element( "Your E-mail:", "email", "text", "", "", "", ' ');
$_form -> _add_element( "Your sex:", "sex", "radio", array('values' => array('m' => 'male', 'f'=>'female'), 'select' => ''), "", "", ' ');
$_form -> _add_element( "Your favourite music:", "music", "checkbox", array('values' => array('techno' => 'techno', 'pop'=> 'Pop', 'randb' => 'R&B'), 'select' => array('techno', 'pop')), "", "", ' ');
$_form -> _add_element( "Your country", "country", "select", array('values' => array('pl' => 'Poland', 'uk'=>'United Kingdom'), 'select' => 'pl'), "", "", ' ');
$_form -> _add_element( "About you", "about", "textarea", "", "", "", ' ');
$_form -> _add_element( "Iformation", "", "html", "If you want register please click Dalej", "", "", ' ');
$_form -> _add_rule( array('name', 'about') );
echo $_form -> _display_form();
</pre>
<br /><br />

</body>
</html>