Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Form check submit ........

    Ciao.
    Codice PHP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    *{ 
        margin:0px; 
        padding:0px
    }
    input,textarea{ 
        width:150px
    }
    textarea{ 
        height:150px 
    }
    </style>
    </head>

    <body>
    <?php 
    function redirect($page){
            
    $host$_SERVER['HTTP_HOST'];
            
    $urirtrim(dirname($_SERVER['PHP_SELF']), '/\\');
            
    $extra$page;
            
    header("Location: ");
            exit();

    function 
    getPost($key){
            return isset(
    $_POST[$key]) ? $_POST[$key] : null;
        }
    function 
    getGet($key){
            return isset(
    $_GET[$key]) ? $_GET[$key] : null;
        }
    function 
    formHasPropriety(){
        
    $hasPropertytrue;
        
    $argsfunc_get_args();
        foreach(
    $args as $arg){
            if(
    is_null(getPost($arg))){
                
    $hasPropertyfalse;
            }
        }
        return 
    $hasProperty;
    }
    if (
    is_null($action=getGet('action'))){
        
    $action'form';
    }
    if (
    $action=='form')

    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>?action=new_item" method="post" name="frm">
    <input name="check_from" type="hidden" value="<?php echo time();?>" />
    <input name="title" type="text" maxlength="50" />

    <textarea name="description" cols="30" rows="30"></textarea>

    <input name="save_item" type="submit" value="Save" />
    </form>
    <?php 
    }
    elseif(
    $action=='new_item')
    {
        if(
    formHasPropriety('check_from','title','description','save_item')){
            
    //validation
            //input filter ie strip_tags 
            
    echo 'Insert new_item';
        }
        else{
            
    redirect('404.php');
        }
    }
    else{
        
    redirect('404.php');

    ?>
    </body>
    </html>
    Che ne pensate può andare ?

    Conoscete un metodo migliore ; ?

    function redirect($page){
    $host= $_SERVER['HTTP_HOST'];
    $uri= rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extra= $page;
    header("Location: http://$host$uri/$extra");
    exit();
    }

    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  2. #2
    Nella furia avevo fatto un erroraccio

    Codice PHP:
    <?php 
    $output
    ='';
    $form= <<<EOD
    <form action="?action=new_item" method="post" name="frm">
    <input name="check_from" type="hidden" value="<?php echo time();?>" />
    <input name="title" type="text" maxlength="50" />

    <textarea name="description" cols="30" rows="30"></textarea>

    <input name="save_item" type="submit" value="Save" />
    </form>
    EOD;
    function 
    redirect($page){
            
    $host$_SERVER['HTTP_HOST'];
            
    $urirtrim(dirname($_SERVER['PHP_SELF']), '/\\');
            
    $extra$page;
            
    header("Location: VEDI SOPRA");
            exit();

    function 
    refresh($page,$time=3){
            
    $extra$page;
            
    header("Refresh: $time; URL=\"$extra\"");
    }
    function 
    getPost($key){
            return isset(
    $_POST[$key]) ? $_POST[$key] : null;
        }
    function 
    getGet($key){
            return isset(
    $_GET[$key]) ? $_GET[$key] : null;
        }
    function 
    formHasPropriety(){
        
    $hasPropertytrue;
        
    $argsfunc_get_args();
        foreach(
    $args as $arg){
            if(
    is_null(getPost($arg))){
                
    $hasPropertyfalse;
            }
        }
        return 
    $hasProperty;
    }
    if (
    is_null($action=getGet('action'))){
        
    $action'form';
    }
    if (
    $action=='form')
    {
        
    $output$form
    }
    elseif(
    $action=='new_item')
    {
        if(
    formHasPropriety('check_from','title','description','save_item')){
            
    //validation
            //input filter ie strip_tags 
            
    redirect('index.php');
        }
        else{
            
    redirect('404.php');
        }
    }
    else{
        
    redirect('404.php');


    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    *{ 
        margin:0px; 
        padding:0px
    }
    input,textarea{ 
        width:150px
    }
    textarea{ 
        height:150px 
    }
    </style>
    </head>

    <body>
    <?php 
    echo $output;
    ?>
    </body>
    </html>
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  3. #3
    :ignore:
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.