Mysmilies.net die Smilies Datenbank

Script oder Datei finden :

 
-Startseite
-Newsarchiv
-Newsletter
-Mein Dreamcodes
-Scripte
-eBooks
-Online Speicher
-Datenbanken
-Webseiten
-Trickfilm
-Web Grafiken
-Bildbearbeiter
-Browser
-EMail Software
-Ftp Clienten
-Betriebssysteme
-Texteditoren
-Wampserver
-Office Pakete
-Antivirus
-System Cleaner
-Recovery Tools
-Php Schnipsel
-Ajax Schnipsel
-VB Schnipsel
-Tutorials
-Workshops
-Webkatalog
-Leserforum
-Erweiterte Suche
-Sitemap
-Impressum
-neuste Downloads

1. Selfphp (1714)
2. Xampp OS X (1609)
3. Xampp Linux (1598)
4. Xampp Windows (1613)

-neuste Tutorials

1. Samsung S20 rooten (1177)
2. Gratis USA Nummer (14531)
3. RAID (13570)
4. Text auf Grafik (14239)


Tutorials Form Gen.

 

Form Gen.

Ein wahnsinns praktisches Teil wenn mal schnell ein Formular benötigt das auch noch gleich mit validiert werden soll.

Script:

<?php
class form_o_mat
{
var $id; //Form name (to identify if it was send)
var $action; //Where should this form post? (if nothing, it self)
var $caption; //Caption to show the user
var $target = "_self"; //What should the target be?
var $style; //If there is a css class for this form, put the name here
var $enctype; //Will automaticly be set to multipart/form-data if there is a form with a file obj.
var $hide = FALSE; //Shuld the form be hidden if there are no errors in the send data?

var $_error=""; //Intern error trigger
var $_error_msg=""; //Intern error message to be displayed
var $_data=""; //Intern usage for storing the form data

function insert_object( $name, $caption, $needed=FALSE, $type="text", $size="", $value="" )
{
$needed_signal = "";

if( isset( $_POST[$this->id] ) )
{
$this->_check_data( $name, $type, $needed );

$value = $_POST[$name];
}
if( $needed == TRUE )
{
$needed_signal = "* ";
}

$return = '<tr><td valign="top"><b>'. $caption .'</b>'. $needed_signal .'</td><td valign="top">';

$value = htmlspecialchars( $value );

switch( $type )
{
case 'password':
$size = preg_replace( "/\D/i", "", $size );
if( !empty( $size ) )
{
$size = 'size="'. $size .'"';
}
$attribs = 'type="password" '. $size;

if( !empty( $value ) )
{
$value = 'value="'. $value .'"';
}

$return .= '<input name="'. $name .'" '. $attribs .' '. $value .'>';
break;
case 'file':
$this->enctype = 'multipart/form-data';

$size = preg_replace( "/\D/i", "", $size );
if( !empty( $size ) )
{
$size = 'size="'. $size .'"';
}
$attribs = 'type="file" '. $size;

if( !empty( $value ) )
{
$value = 'value="'. $value .'"';
}

$return .= '<input name="'. $name .'" '. $attribs .' '. $value .'>';
break;
case 'textarea':
$size = explode( 'x', $size );
if( !empty( $size[0] ) AND !empty( $size[1] ) )
{
$size = 'cols="'. $size[0] .'" rows="'.$size[1] .'"';
}

$return .= '<textarea name="'. $name .'" '. $size .'">'. $value .'</textarea>';
break;
default:
$size = preg_replace( "/\D/i", "", $size );
if( !empty( $size ) )
{
$size = 'size="'. $size .'"';
}
$attribs = 'type="text" '. $size;

if( !empty( $value ) )
{
$value = 'value="'. $value .'"';
}

$return .= '<input name="'. $name .'" '. $attribs .' '. $value .'>';
}

$return .= '</td><td valign="top">'. $this->_error_msg .'</td></tr>';

$this->_data .= $return;
return true;
}

function insert_object_group( $name, $caption, $value, $needed="", $type="", $description="" )
{
if( isset( $_POST[$this->id] ) )
{
$this->_check_data( $name, $type, $needed );
}
if( $needed == TRUE )
{
$needed_signal = "* ";
}

$return = '<tr><td valign="top"><b>'. $caption .'</b>'. $needed_signal .'</td><td valign="top">';

if( !is_array( $value ) OR ( !empty( $description ) AND !is_array( $description ) ) )
{
return false;
}

switch( $type )
{
case 'radio':
if( empty( $description ) )
{
$description = $value;
}

foreach( $value as $key => $item )
{
if( isset( $_POST[$this->id] ) AND $_POST[$name] == $item )
{
$checked = "checked";
}
else
{
$checked = "";
}
$return .= '<lable><input type="radio" name="'. $name .'" value="'. $item .'" '. $checked .'>'. $description[$key] .'</lable><br/>';
}
break;
case 'check':
if( empty( $description ) )
{
$description = $value;
}

foreach( $value as $key => $item )
{
if( @in_array( $item, $_POST[$name] ) )
{
$checked = "checked";
}
else
{
$checked = "";
}
$return .= '<lable><input type="checkbox" name="'. $name .'[]" value="'. $item .'" '. $checked .'>'. $description[$key] .'</lable><br/>';
}
break;
default:
$return .= '<select name="'. $name .'">';

if( empty( $description ) )
{
$description = $value;
}
$return .= '<option value="">-- select what is true --</option>';
foreach( $value as $key => $item )
{
if( isset( $_POST[$this->id] ) AND $_POST[$name] == $item )
{
$selected = "selected";
}
else
{
$selected = "";
}
$return .= '<option value="'. $item .'" '. $selected .'>'. $description[$key] .'</option>';
}

$return .= '</select>';
}

$return .= '</td><td valign="top">'. $this->_error_msg .'</td></tr>';

$this->_data .= $return;
return true;
}

function _check_data( $name, $type, $needed )
{
if( $type == TRUE AND $needed != FALSE )
{
if( $type == 'check' )
{
$string = "";
$i = "";
if( isset( $_POST[$name] ) )
{
$i = count( $_POST[$name] );
}
while( $i > 0 )
{
$i--;
$string .= 'i';
}
}
else
{
$string = $_POST[$name];
}
$count = strlen( $string );

if( $needed == 1 )
{
if( $count >= $needed )
{
$this->_error_msg = "";
return true;
}
else
{
$this->_error_msg = "this information must be entered";
$this->_error = TRUE;
return false;
}
}
else
{
$needed = explode( "-", $needed );
if( !empty( $needed[1] ) )
{
if( ( $count <= max( $needed[0], $needed[1] ) ) AND ( $count >= min( $needed[0], $needed[1] ) ) )
{
$this->_error_msg = "";
return true;
}
else
{
$this->_error_msg = 'must be '. min( $needed[0], $needed[1] ) .' to '. max( $needed[0], $needed[1] ) .' characters long!';
$this->_error = TRUE;
return false;
}
}
else
{
if( empty( $needed[1] ) )
{
if( $count >= $needed[0] )
{
$this->_error_msg = "";
return true;
}
else
{
$this->_error_msg = 'this information must be atleast '. $needed[0] .' characers long!';
$this->_error = TRUE;
return false;
}
}
}
}
}
else
{
$this->_error_msg = "";
return true;
}
}

function dump_form()
{
$style = "";

if( !empty( $this->style ) )
{
$style = 'class="'. $this->style .'"';
}
if( empty( $this->action ) )
{
$this->action = $_SERVER['REQUEST_URI'];
}
if( !empty( $this->caption ) )
{
$result = '<h2>'. $this->caption .'</h2>';
}
if( !empty( $this->enctype ) )
{
$enctype = 'enctype="'. $this->enctype .'"';
}

$result .= '<table>'. $this->_data .'<tr><td valign="top">&nbsp;</td><td valign="top">* This information is required<td valign="top"></td></tr></table>';
$return = '<form action="'. $this->action .'" method="post" target="'. $this->target .'" '. $style .'>';
$return .= $result;
$return .= '<input name="'. $this->id .'" type="submit"><input type="reset"></form>';

if( $this->_error == FALSE AND $this->hide == TRUE AND isset( $_POST[$this->id] ) )
{
return true;
}
else
{
return $return;
}

}
}
?>

 
Seiten : 1
hinzugefügt am : 28.01.2005
Autor : NA
Listings ID : 643
Status zum lesen : Gast
gelesen : 6987 mal
[Druckansicht] [Lesercharts] [RSS] [zur Übersicht]
 
 

Die Möglichkeit diesen Artikel zu verlinken :

HTML-Code:

Code zum Einbinden in ein Forum:


Hinweis : Das lesen des Artikels Form Gen. - listings ID: 643 auf Dreamcodes, sowie Link Verweise auf Internetseiten fremder Anbieter erfolgen auf eigene Gefahr. Dreamcodes haftet nicht für Schäden, die aus der Verwendung des Inhaltes der Artikel erfolgen könnten. Schadenersatzansprüche, aus welchem Rechtsgrund auch immer, sind ausgeschlossen !
-Live Statistik
Datum: 28.03.2024
Uhrzeit: 17:36 Uhr
Online: 10 User
User heute: 7575
User allgem.: 33496177

Eingeloggt als Gast
-Download des Monats
-
-unsere Monats Umfrage
Welche Serie ist besser?

The Blacklist
House of the Dragon
Die Ringe der Macht
The Sandman
Manifest

-unsere Bestseller