10. januar 2009 - 16:21 Der er 1 løsning

Begrænsning af upload

Jeg har en side med en mail form hvor man skal kunne sende et billede fra.

Jeg har fået det hele til at virke med afsendelsen men hvordan for jeg lavet det sådan at den kun acceptere .jpg og filer under 1 MB

<?php
# PHPFMG_ID:'20090110-4e7e'
# Date : 20090110 10:16:45
# Generated By Free PHP Formmail Generator : http://phpfmg.sourceforge.net
# -----------------------------------------------------------------------------
define( 'PHPFMG_ID' , '20090110-4e7e' );
define( 'PHPFMG_TO' , 'mr.lars@gmail.com' );
define( 'PHPFMG_REDIRECT', '' );

define( 'PHPFMG_ROOT_DIR' , dirname(__FILE__) );
define( 'PHPFMG_SAVE_FILE' , PHPFMG_ROOT_DIR . '/form-data-log.php' ); // save submitted data to this file
define( 'PHPFMG_EMAILS_LOGFILE' , PHPFMG_ROOT_DIR . '/email-traffics-log.php' ); // log email traffics to this file
define( 'PHPFMG_ADMIN_URL' , 'admin.php' );

define( 'PHPFMG_CC' , '' );
define( 'PHPFMG_BCC', '' );
define( 'PHPFMG_SUBJECT' , "fangst" );
define( 'PHPFMG_RETURN_SUBJECT' , "" ); // auto response mail subject
define( 'PHPFMG_CHARSET' , 'UTF-8' );
define( 'PHPFMG_MAIL_TYPE' , 'html' ); // send mail in html format or plain text.
define( 'PHPFMG_ACTION' , '' ); // delivery method
define( 'PHPFMG_NO_FROM_HEADER' , '' ); // don't make up From: header.

define( 'HOST_NAME',getEnv( 'SERVER_NAME' ) );
define( 'PHP_SELF', getEnv( 'SCRIPT_NAME' ) );

define( 'ERR_MISSING', '<div class="form_error_title">Please check the required fields</div>' );
define( 'ERR_EMAIL', ' (not a valid e-mail address)' );
define( 'ERR_CREDIT_CARD_NUMBER', 'Please check the credit card number : ' );
define( 'ERR_CREDIT_CARD_EXPIRED', 'Please check the credit card expiry date : ' );
define( 'ERR_SELECT_UPLOAD', 'Please select upload file : ' );
define( 'ERR_CAPTCHA', 'Security Code' );

set_magic_quotes_runtime(0);
error_reporting( E_ERROR );
session_start();
# -----------------------------------------------------------------------------

function phpfmg_auto_response_message(){
    ob_start();
?>

<?php
    $msg = ob_get_contents() ;
    ob_end_clean();
    return trim($msg);
}


function phpfmg_mail_template(){
    ob_start();
?>

<?php
    $msg = ob_get_contents() ;
    ob_end_clean();
    return trim($msg);
}

# --- Array of Form Elements ---
$form_mail[] = array( "name" => "field_0", "text" => "billede",  "type" => "attachment", "required" => "" ) ;

?>
<?php
/**
* Copyright (C) : http://www.formmail-maker.com
*/

function phpfmg_sendmail( &$form_mail ) {
    if( !isset($_POST["formmail_submit"]) ) return ;

    $isHideForm = false ;
    $sErr = checkPass($form_mail);
   
    if( isset($_SESSION['fmgCaptchCode']) && strtoupper($_POST['fmgCaptchCode']) != strtoupper($_SESSION['fmgCaptchCode']) ){
        $sErr['fields'][] = 'phpfmg_captcha';
        $sErr['errors'][] = ERR_CAPTCHA;
    };
   
    if( empty($sErr['fields']) ){
        sendFormMail( $form_mail, PHPFMG_SAVE_FILE ) ;
        $isHideForm = true;
        $redirect = PHPFMG_REDIRECT;
        if( strlen(trim($redirect)) ):
            header( "Location: $redirect" );
            exit;
        endif;
    };

    return array(
        'isHideForm' => $isHideForm,
        'error'      => $sErr ,       
    );
}



function    sendFormMail( $form_mail, $sFileName = ""  )
{
    $to        = filterEmail(PHPFMG_TO) ;
    $cc        = filterEmail(PHPFMG_CC) ;
    $bcc      = filterEmail(PHPFMG_BCC) ;
    $subject  = PHPFMG_SUBJECT ;
    $from      = "phpfmg@" . HOST_NAME ;
    $fromName  = "";
    $titleOfSender = '';
   
    $strip    = get_magic_quotes_gpc() ;
    $content  = '' ;
    $style    = 'font-family:Verdana, Arial, Helvetica, sans-serif; font-size : 13px; color:#474747;padding:6px;border-bottom:1px solid #cccccc;' ;
    $tr        = array() ; // html table
    $csvValues = array();
    $cols      = array();
   
    for( $i = 0; $i < count( $form_mail ); $i ++ ){
        $field_type = strtolower($form_mail[ $i ][ "type" ]);
        if( 'sectionbreak' == $field_type ){
            continue;
        };
       
        $value    = trim( $_POST[ $form_mail[ $i ][ "name" ] ] );
        $value    = $strip ? stripslashes($value) : $value ;
        if( 'attachment' == $field_type ){
            $value = $_FILES[ $form_mail[ $i ][ "name" ] ]['name'];
        };

        $content    .= $form_mail[ $i ][ "text" ] . " \t : " . $value ."\n";
        $tr[]        = "<tr> <td valign=top style='{$style};width:300px;border-right:1px solid #cccccc;'>" . $form_mail[ $i ][ "text" ] . "&nbsp;</td> <td valign=top style='{$style};'>" . nl2br($value) . "&nbsp;</td></tr>" ; 
        $csvValues[] = csvfield( $value );
        $cols[]      = csvfield( $form_mail[ $i ][ "text" ] );
       
        switch( $field_type ){
            case "sender's email" :
                $from = filterEmail($value) ;
                break;
            case "sender's name" :
                $fromName = filterEmail($value) ;
                break;
            case "titleofsender" :
                $titleOfSender = $value ;
                break;
            default :
                // nothing                   
        };
       
    };
   
    $isHtml = 'html' == PHPFMG_MAIL_TYPE ;
   
    if( $isHtml ) {
        $content = "<table cellspacing=0 cellpadding=0 border=0 >\n" . join( "\n", $tr ) . "\n</table>" ;
    };
   
    if( '' != $fromName ) {
        $from = filterEmail("$fromName <{$from}>",array(",", ";")) ; // no multiple emails are allowed.
    };
   
    $fields = array(
        '%NameOfSender%' => $fromName,
        '%TitleOfSender%' => $titleOfSender,
        '%DataOfForm%'  => $content,
    );
   
    $esh_mail_template = trim(phpfmg_mail_template());
    if( !empty($esh_mail_template) ){
        $esh_mail_template = phpfmg_adjust_template($esh_mail_template);
        $content = phpfmg_parse_mail_body( $esh_mail_template, $fields );
    };
   
    if( $isHtml ) {
        $content = phpfmg_getHtmlContent( $content );
    };
    mailAttachments( $to , $subject , $content,  $from,  $cc , $bcc, PHPFMG_CHARSET ) ;

    if( ! appendToFile( $sFileName, csvfield(date("Y-m-d H:i:s")) . ',' . csvfield($_SERVER['REMOTE_ADDR']) .',' . join(",",$csvValues), csvfield('Date') . ',' . csvfield('IP') . ',' . join(",",$cols) ) ){
        mailReport( $content, $sFileName );
    };

    mailAutoResponse( $from, $to, $fields ) ;
}


function csvfield( $str ){
    $str = str_replace( '"', '""', $str );
    return '"' . trim($str) . '"';
}


function    mailAttachments( $to = "" , $subject = "" , $message = "" , $from = "phpfmg@gmail.com" , $cc = "" , $bcc = "", $charset = "UTF-8", $type = 'FormMail' ){
   
    if( ! strlen( trim( $to ) ) ) return "Missing \"To\" Field." ;

    $boundary = "====_My_PHP_Form_Generator_" . md5( uniqid( srand( time() ) ) ) . "===="; 
    $content_type = 'html' == PHPFMG_MAIL_TYPE ? "text/html" : "text/plain" ;
   
    // setup mail header infomation
    $headers =  'Y' == PHPFMG_NO_FROM_HEADER ? '' :  "From: $from\r\n";
    if ($cc) $headers .= "CC: $cc\r\n"; 
    if ($bcc) $headers .= "BCC: $bcc\r\n"; 

    $plainHeaders = $headers ; // for no attachments header
    if(  'html' == PHPFMG_MAIL_TYPE ) {
        $plainHeaders .= 'MIME-Version: 1.0' . "\r\n";
        $plainHeaders .= "Content-type: text/html; charset={$charset}" . "\r\n";
    };
   
    $headers .= "MIME-Version: 1.0\nContent-type: multipart/mixed;\n\tboundary=\"$boundary\"\n"; 
    $txtMsg = "\nThis is a multi-part message in MIME format.\n" . 
                    "\n--$boundary\n" .
                    "Content-Type: {$content_type};\n\tcharset=\"$charset\"\n\n"  . $message . "\n";
   
    //create mulitipart attachments boundary
    $sError = "" ;
    $nFound = 0;

    if( array_key_exists($GLOBALS['phpfmg_files_content']) && '' != $GLOBALS['phpfmg_files_content'] ){
       
        // use previous encoded content
        $sEncodeBody = $GLOBALS['phpfmg_files_content'] ;
        $nFound = true ;
       
    }else{

        // parse attachments content
        foreach( $_FILES as $aFile ){
            $sFileName = $aFile[ "tmp_name" ] ;
            $sFileRealName = $aFile[ "name" ] ;
            if( is_uploaded_file( $sFileName ) ):
               
                if( $fp = @fopen( $sFileName, "rb" ) ) :
                    $sContent = fread( $fp, filesize( $sFileName ) );
                    $sFName = basename( $sFileRealName ) ;
                    $sMIME = getMIMEType( $sFName ) ;
                   
                    $bPlainText = ( $sMIME == "text/plain" ) ;
                    if( $bPlainText ) :
                        $encoding = "" ;
                    else:
                        $encoding = "Content-Transfer-Encoding: base64\n"; 
                        $sContent = chunk_split( base64_encode( $sContent ) ); 
                    endif;
                   
                    $sEncodeBody .=    "\n--$boundary\n" . 
                                        "Content-Type: $sMIME;\n" . 
                                        "\tname=\"$sFName\"\n" .
                                        $encoding . 
                                        "Content-Disposition: attachment;\n" . 
                                        "\tfilename=\"$sFName\"\n\n" .
                                        $sContent . "\n" ;
                    $nFound ++;                                               
                else:
                    $sError .= "<br>Failed to open file $sFileName.\n" ;
                endif; // if( $fp = fopen( $sFileName, "rb" ) ) :
               
            else:
                $sError .= "<br>File $sFileName doesn't exist.\n" ;
            endif; //if( file_exists( $sFileName ) ):
        }; // end foreach
        $sEncodeBody .= "\n\n--$boundary--" ;

    }; // if
   
    $sSource = $txtMsg . $sEncodeBody ;

    if( 'fileonly' != PHPFMG_ACTION ) {
      $nFound ? mail( $to, $subject, $sSource, $headers  )
              : mail( $to, $subject, $message, $plainHeaders );
    };

    //phpfmg_log_mail( $to, $subject, ($nFound ? $headers . $sSource : $plainHeaders . $message), '', $type );
    phpfmg_log_mail( $to, $subject, ($nFound ? $headers . $txtMsg : $plainHeaders . $message), '', $type ); // no log for attachments
   
    return $sError ;       
}



function mailAutoResponse( $to, $from, $fields = false ){
    if( !formIsEMail($to) ) return ERR_EMAIL ; // one more check for spam robot
    $body = trim(phpfmg_auto_response_message());
    if( empty($body) ){
      return false ;
    };
   
    $subject = PHPFMG_RETURN_SUBJECT;
    $isHtml = 'html' == PHPFMG_MAIL_TYPE ;
    $body = phpfmg_adjust_template($body);
    $body = phpfmg_parse_mail_body($body,$fields);
    if( $isHtml ) {
        $body = phpfmg_getHtmlContent( $body );
    };       
   
    return mailAttachments( $to , $subject , $body,  filterEmail($from),  '' , '', PHPFMG_CHARSET, 'AutoResponseEmail' ) ;
}


function phpfmg_log_mail( $to='', $subject='', $body='', $headers = '', $type='' ){
    $sep = str_repeat('----',20) . "\r\n" ;
    appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . "\t{$type}\r\n"  . $sep . "To: {$to}\r\nSubject: {$subject}\r\n" . $headers . $body  . "\r\n" . $sep  ) ;
}


function phpfmg_getHtmlContent( $body ){
    $html = "
<html>
    <title>Your Form Mail Content | htttp://phpfmg.sourceforge.net</title>
<style type='text/css'>
    body, td{
        font-family : Verdana, Arial, Helvetica, sans-serif;
        font-size : 13px;
    }
</style>
    <body>
   
"
    . $body .
"   
   
    </body>
</html>       
";
    return $html ;


function phpfmg_adjust_template( $body ){
    $isHtml = 'html' == PHPFMG_MAIL_TYPE ;
    return $isHtml && preg_match( "/<[^<>]+>/", $body ) ? $body : nl2br($body);

}

function phpfmg_parse_mail_body( $body, $fields = false ){
    if( !is_array($fields) )
        return $body ;
   
    foreach( $fields as $name => $value ){
        $body = preg_replace( '/' .$name. '/ims', $value ,$body );
    };
    return trim($body);
}



# filter line breaks to avoid emails injecting
function filterEmail($email, $chars = ''){
    $email = trim(str_replace( array("\r","\n"), '', $email ));
    if( is_array($chars) ) $email = str_replace( array("\r","\n"), '', $email );
    return $email;
}



function mailReport( $content = "", $file = '' ){
    $content = "
Dear Sir or Madam,

Your online form at " . HOST_NAME . PHP_SELF . " failed to save data to file. Please make sure the web user has permission to write to file \"{$file}\". If you don't know how to fix it, please forward this email to technical support team of your web hosting company or your Administrator.

PHPFMG
- PHP FormMail Generator
";
    mail(PHPFMG_TO, "Error@" . HOST_NAME . PHP_SELF, $content );
}


function    remove_newline( $str = "" ){
    return str_replace( array("\r\n", "\r", "\n"), array('\r\n', '\r', '\n'), $str );
}
/*
function    remove_newline( $str = "" ){
    $newliner = "<!--esh_newline-->" ; // replace \r\n with $newliner ;
    $newtaber = "<!--esh_newtaber-->" ; // replace \t with $newtaber ;
    $str = ereg_replace( "\t", $newtaber, $str );
    $str = ereg_replace( "\r\n", $newliner, $str );
    return ereg_replace( "\n", $newliner, $str );
}
*/


function    checkPass( $form_mail = array() )
{

    $names = array();
    $labels = array();
   
    for( $i = 0, $N = count( $form_mail ); $i < $N; $i ++ ){
        $type    = strtolower( $form_mail[ $i ][ "type" ]  );
        $value    = trim( $_POST[ $form_mail[ $i ][ "name" ] ] );
        $required = $form_mail[ $i ][ "required" ] ;
        $text    = stripslashes( $form_mail[ $i ][ "text" ] );
       
        // simple check the field has something keyed in.
        if( !strlen($value) && (  $required == "Required" ) && $type != "attachment" ){
            $names[] = $form_mail[ $i ][ "name" ];
            $labels[]  = $text;
            //return ERR_MISSING . $text  ;
            continue;
        }; 

        // verify the special case
        if(
            ( strlen($value) || $type == "attachment" )
            &&  $required == "Required"
        ):
       
            switch( $type ){
                case     strtolower("Sender's Name") :
                          break;
                case     strtolower("Generic email"):
                case     strtolower("Sender's email"):
                          if( ! formIsEMail($value) )    {
                                $names[] = $form_mail[ $i ][ "name" ];
                                $labels[]  = $text . ERR_EMAIL;
                            //return ERR_EMAIL . $text ;
                          };
                          break;
                case    "text" :
                            break;
                case     "textarea" :
                            break;
                case    "checkbox" :
                case     "radio" :
                            break;
                case     "select" :
                            break;
                case     "attachment" :
                            $upload_file = $_FILES[ $form_mail[ $i ]["name"] ][ "tmp_name" ] ;
                            if( ! is_uploaded_file($upload_file)  ){
                                $names[] = $form_mail[ $i ][ "name" ];
                                $labels[]  = $text;
                                //return  ERR_SELECT_UPLOAD . $text;
                            };
                            break;
                case strtolower("Date(MM-DD-YYYY)"):
                            break;
                case strtolower("Date(MM-YYYY)"):
                            break;
                case strtolower("CreditCard(MM-YYYY)"):
                            if( $value < date("Y-m") ) {
                                $names[] = $form_mail[ $i ][ "name" ];
                                $labels[]  = $text;
                                //return ERR_CREDIT_CARD_EXPIRED  . $text;
                            };
                            break;
                case strtolower("CreditCard#"):
                            if( !formIsCreditNumber( $value )  ) {
                                $names[] = $form_mail[ $i ][ "name" ];
                                $labels[]  = $text;
                                //return ERR_CREDIT_CARD_NUMBER  . $text ;
                            };
                            break;
                case strtolower("Time(HH:MM:SS)"):
                            break;
                case strtolower("Time(HH:MM)"):
                            break;
                default :
                    //return $sErrRequired . $form_mail[ $i ][ "text" ];
            }; // switch
        endif;
    }; // for
   
    return array(
      'fields' => $names,
      'errors' => $labels, 
    );
}



function formSelected( $var, $val )
{
    echo ( $var == $val ) ? "selected" : "";
}



function formChecked( $var, $val )
{
    echo ( $var == $val ) ? "checked" : "";
}



function    formIsEMail( $email ){
        return ereg( "^(.+)@(.+)\\.(.+)$", $email );
}



function    selectList( $name, $selectedValue, $start, $end, $prompt = "-Select-", $style = "" )
{
    $tab = "\t" ;
    print "<select name=\"$name\" $style>\n" ;
    print $tab . "<option value=''>$prompt</option>\n" ;
    $nLen = strlen( "$end" ) ;
    $prefix_zero = str_repeat( "0", $nLen );
    for( $i = $start; $i <= $end ; $i ++ ){
        $stri = substr( $prefix_zero . $i, strlen($prefix_zero . $i)-$nLen, $nLen );
        $selected = ( $stri == $selectedValue ) ? " selected " : "" ;
        print $tab . "<option value=\"$stri\" $selected >$stri</option>\n" ;
    }
    print "</select>\n\n" ;
}



# something like CreditCard.pm in perl CPAN
function formIsCreditNumber( $number ) {
   
    $tmp = $number;
    $number = preg_replace( "/[^0-9]/", "", $tmp );

    if ( preg_match(  "/[^\d\s]/", $number ) )  return 0;
    if ( strlen($number) < 13  && 0+$number ) return 0; 

    for ($i = 0; $i < strlen($number) - 1; $i++) {
        $weight = substr($number, -1 * ($i + 2), 1) * (2 - ($i % 2));
        $sum += (($weight < 10) ? $weight : ($weight - 9));
    }

    if ( substr($number, -1) == (10 - $sum % 10) % 10  )  return $number;
    return $number;
}


/* ---------------------------------------------------------------------------------------------------
    Parameters: $sFileName
    Return :
        1. "" :  no extendsion name, or sFileName is empty
        2. string: MIME Type name of array aMimeType's definition.
  ---------------------------------------------------------------------------------------------------*/
function    getMIMEType( $sFileName = "" ) {
    $sFileName = strtolower( trim( $sFileName ) );
    if( ! strlen( $sFileName  ) ) return "";
   
    $aMimeType = array( 
        "txt" => "text/plain" ,
        "pdf" => "application/pdf" ,
        "zip" => "application/x-compressed" ,
       
        "html" => "text/html" ,
        "htm" => "text/html" ,
       
        "avi" => "video/avi" ,
        "mpg" => "video/mpeg " ,
        "wav" => "audio/wav" ,
       
        "jpg" => "image/jpeg " ,
        "gif" => "image/gif" ,
        "tif" => "image/tiff " ,
        "png" => "image/x-png" ,
        "bmp" => "image/bmp" 
    );
    $aFile = split( "\.", basename( $sFileName ) ) ;
    $nDiminson = count( $aFile ) ;
    $sExt = $aFile[ $nDiminson - 1 ] ; // get last part: like ".tar.zip", return "zip"
   
    return ( $nDiminson > 1 ) ? $aMimeType[ $sExt ] : ""; 
}



function    appendToFile( $sFileName = "", $line = "", $dataColumnsLine = '' ){
    if( !$sFileName || !$line ) return 0;

    $isExists = file_exists( $sFileName );
    $hFile = @fopen( "$sFileName", "a+w" );
    $nBytes = 0;
    if( $hFile ){
        if( !$isExists && false !== strpos(strtolower(basename($sFileName)), '.php') ){
            fputs( $hFile, "<?php exit(); /* For security reason. To avoid public user downloading below data! */?>\r\n");
            if( !empty($dataColumnsLine) ){
                fputs($hFile,$dataColumnsLine."\r\n");
            };
        };
        $nBytes = fputs( $hFile , trim($line)."\r\n" );
        fclose( $hFile );
    };
    return $nBytes ;
}

function phpfmg_get_csv_header($form_mail){
    global $form_mail;
    $csvValues = array();
    for( $i = 0; $i < count( $form_mail ); $i ++ ){
        $csvValues[] = csvfield( $form_mail[ $i ][ "text" ] );
    };
    return join(",",$csvValues) ;
}



function phpfmg_rand( $len = 4 ){
    $md5 = md5( uniqid(rand()) );
    return $len > 0 ? substr($md5,0,$len) : $md5 ;
}




function phpfmg_show_captcha(){
    $url = PHPFMG_ADMIN_URL . '?mod=captcha&func=get&tid=' ;
?>
    <img id="phpfmg_captcha_image" src="<?php echo $url . time();?>" onclick="this.src='<?php echo $url ;?>'+Math.random();" border=0 style="cursor:pointer;" title="Click the image to reload. PHP FormMail Generator at http://phpfmg.sourceforge.net">
    <a href="http://phpfmg.sourceforge.net" onclick="document.getElementById('phpfmg_captcha_image').src='<?php echo $url ;?>'+Math.random();return false;" style="color:#474747;" title="Reload PHP FormMail Generator Security Image" >Reload Image</a><br>
    <input type='text' name="fmgCaptchCode" value="" class="fmgCaptchCode" style="width:73px;" > 
<?php
}



function phpfmg_dropdown( $name, $options, $select = '- Select -', $extra = '', $isReturn = false ){
    $dropdown = array();
    $list = explode( '|', $options );
    $dropdown[] = "<select name='{$name}' class='text_select' {$extra} >";
    $dropdown[] = "<option value='' >{$select}</option>";
    if( is_array($list) ){
        foreach( $list as $opt ){
            //$value = HtmlSpecialChars( $opt );
            $value = $opt;
            $selected = $value == $_POST[ $name ] ? 'selected' : '' ;
            $dropdown[] = "<option value=\"{$value}\" {$selected}>{$opt}</option>";
        };
    };
    $dropdown[] = "</select>\n";
    $s = join("\t\n",$dropdown);

    if( $isReturn )
        return $s;
    else
        echo $s ;
}



function phpfmg_choice( $type, $name, $options, $isReturn = false ){
    $radios = array();
    $list = explode( '|', $options );
    if( is_array($list) ){
        $i = 0 ;
        foreach( $list as $opt ){
            //$value = HtmlSpecialChars( $opt );
            $value = $opt;
            $id = "{$name}_{$i}";
            $newname = 'checkbox' == $type ? "Checkbox" . substr("00".($i+1), strlen("00".($i+1))-2,2) . "_" . $name : $name;
            $checked = $value == $_POST[ $newname ] ? 'checked' : '' ;
            $radios[] = "<input type='{$type}' name='{$newname}' id='{$id}'  value=\"{$value}\"  {$checked} class='form_{$type}' ><label class='form_{$type}_text' onclick=\"fmgHandler.choice_clicked('{$id}');\" onmouseover=\"this.className='form_{$type}_text form_choice_over';\" onmouseout=\"this.className='form_{$type}_text form_choice_out';\">{$opt}</label><br />";
            $i ++ ;
        };
    };
    $s = join("\t\n",$radios);

    if( $isReturn )
        return $s;
    else
        echo $s ;
}


function phpfmg_radios( $name, $options, $isReturn = false ){
    return phpfmg_choice( 'radio', $name, $options, $isReturn );
}


function phpfmg_checkboxes( $name, $options, $isReturn = false ){
    return phpfmg_choice( 'checkbox', $name, $options, $isReturn );
}


function phpfmg_header(){
?>
<html>
<head>
    <title>PHP FormMail Generator - A tool to create ready-to-use web forms in a flash </title>
    <meta name="keywords" content="PHP FormMail Generator, Free Form, Form Builder, Form Creator, phpFormMailGen, Customized Web Forms, phpFormMailGenerator,formmail.php, formmail.pl, formMail Generator, ASP Formmail, ASP form, PHP Form, Generator, phpFormGen, phpFormGenerator, anti-spam, web hosting">
    <meta name="description" content="PHP formMail Generator - A tool to ceate ready-to-use web forms in a flash">
    <meta name="generator" content="PHP Mail Form Generator, phpfmg.sourceforge.net">

<style type='text/css'>
body, .form_field, .form_required, .form_description, .form_button{
    font-family : Verdana, Arial, Helvetica, sans-serif;
    font-size : 13px;
    color : #474747;
}

.phpfmg_form, .form_description, .form_footer{
    padding-left: 10px;
    padding-bottom: 10px;
    width: 418px;
}

.form_field, .form_required, .form_description, .form_button{
    font-weight : bold;
}

.form_required{
    color:red;
}

.field_block{
    padding: 5px;
}

.form_submit_block{
    padding-top: 10px;
}

.form_text{
}

.text_box, .text_area, .text_select {
    width:300px;
}

.text_area{
    height:80px;
}

.form_error_title{
    font-weight: bold;
    color: red;
}

.form_error{
    background-color: #F4F6E5;
    border: 1px dashed #ff0000;
    padding: 16px;
    color : black;
    margin: 10px;
}

.form_error_highlight{
    background-color: #F4F6E5;
    border-bottom: 1px dashed #dedede;
}


.form_button{
    width:  80px;
    height: 28px;
}


.form_choice_over{
    background-color: #dedede;
    cursor: pointer;
}

.form_choice_out{
}


</style>

<script type="text/javascript">

function PHPFMG(){
    this.$ = function( id ){
        return document.getElementById(id);
    };
   
    this.highlight_fields = function( fields ){
        var A = fields.split(',');
        for( var i = 0, N = A.length; i < N; i ++ ){
            var E = this.$( A[i] + '_div' );
            if( E ){
                E.className += ' form_error_highlight';
            };
        };
    };
   
    this.choice_clicked = function( id ){
        this.$(id).checked = !this.$(id).checked ;
    };
   
}
var fmgHandler = new PHPFMG();

</script>

</head>

<body  marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">

<div class='form_description'>

</div>
<?php
}


function phpfmg_footer(){
?>

<div class='form_footer'>

</div>
<!-- -------------------------------------- Copyright -------------------------------------- -->

    <br><br>
   
    <div style="padding-left:10px; font-size:11px;color:#cccccc;text-decoration:none;">
        :: <a href="http://phpfmg.sourceforge.net" target="_blank" title="Free Mailform Maker: Create read-to-use Web Forms in a flash" style="color:#cccccc;text-decoration:none;font-weight:bold;">PHP FormMail Generator</a> ::
    </div>
    <br><br><br>

</body>
</html>
<?php
}
?>
Avatar billede iss Novice
10. januar 2009 - 20:53 #1
<input type="hidden" name="MAX_FILE_SIZE" value="1M" /> og accept="image/jpeg" i din file input, dog er der ikke nogle browsere jeg lige kan nævne der overholder det, dog.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester