Login   Register  
PHP Classes
elePHPant
Icontem

File: sample2.html

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of masa918  >  Form taglib classes  >  sample2.html  >  Download  
File: sample2.html
Role: ???
Content type: text/plain
Description: sample html file ( with button action)
Class: Form taglib classes
Simple HTML Form taglib
Author: By
Last change:
Date: 2002-04-24 12:06
Size: 2,026 bytes
 

Contents

Class file image Download
<?php
class Action{
  function act_commit(&$form){
  
    $id = $form->get("id");
    if($id == ""){
      return "Login ID field was required !!";
    }
    elseif($id == "admin"){
      if($form->get("pswd") != "admin"){
        return "Login failed!!";
      }
    }
    else{
      return "Login failed!!";
    }
    //  clean http request parameter
    $form->clear();
    return "Congratulations!!";
  }
  function act_confirm(&$form)
  {
    return "are you sure ?";
  }
}
$action =& new Action();
$form =& HTML_Form::instance();
//
// execute when "commit" submit button was pushed
//
$result["ok"]  = $form->doAction("ok",$action,"act_commit");
//
// execute when "confirm" submit button was pushed 
//
$result["login"] = $form->doAction("login",$action,"act_confirm");
?>
<html>
  <head>
    <title>title</title>
  </head>
  <body bgcolor="#ffffff">
  <div align="center">
  <form method="POST" name="test">
    <h2>PTag Test Page2</h2>
    <table>
      <tr>
        <!-- Textfield test -->
        <td>Login Id</td>
        <td><form:text name="id" size="10" class="text"/></td>
      </tr>
      <tr>
        <!-- Password test -->
        <td>Password</td>
        <td><form:password name="pswd" size="10"/></td>
      </tr>
      <tr>
        <td colspan="2" align="center">
          <?php
          if($_POST["login"] != ""){
            $name = "ok";
            $msg = "login";
          }
          else{
            $name = "login";
            $msg = "ok";
          }
          ?>
          admin/admin is correct id and password<br/>
          <input type="submit" name="$name" value="$name"/>&nbsp;&nbsp;
          <input type="reset"  name="reset"  value="reset"/>
          
        </td>
      </tr>
      <tr>
        <td colspan="2" align="center"><font color="red"><?php 
          print "<br>";
          print($result[$msg]);
        ?></font></td>
      </tr>
    </table>
  </form>
  </div>
  </body>
</html>