Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di ada50
    Registrato dal
    Aug 2009
    Messaggi
    27

    Aiuto form iscrizione a numero chiuso

    Devo realizzare un form di iscrizione ad un percorso psicologico che preveda un numero chiuso di iscritti. Di php ammetto di saperne quasi niente, il risultato che vorrei ottenere è che arrivato a 20 iscritti premendo il tasto submit invece di ricevere i dati su un indirizzo mail si aprisse una pagina con la data di inizio del prossimo percorso, il codice che ho usato per l'nvio dei dati è questo:

    <?php
    function ValidateEmail($email)
    {
    $pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
    return preg_match($pattern, $email);
    }

    if($_SERVER['REQUEST_METHOD'] == 'POST')
    {
    $mailto = 'miamail@gmail.com';
    $mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
    $subject = 'Contact Information';
    $message = 'Values submitted from web site form:';
    $success_url = '';
    $error_url = '';
    $error = '';
    $autoresponder_from = 'miamail@gmail.com';
    $autoresponder_subject = 'grazie';
    $autoresponder_message = 'grazie grazie';
    $eol = "\n";
    $max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
    $boundary = md5(uniqid(time()));

    $header = 'From: '.$mailfrom.$eol;
    $header .= 'Reply-To: '.$mailfrom.$eol;
    $header .= 'MIME-Version: 1.0'.$eol;
    $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
    $header .= 'X-Mailer: PHP v'.phpversion().$eol;
    if (!ValidateEmail($mailfrom))
    {
    $error .= "The specified email address is invalid!\n
    ";
    }

    if (!empty($error))
    {
    $errorcode = file_get_contents($error_url);
    $replace = "##error##";
    $errorcode = str_replace($replace, $error, $errorcode);
    echo $errorcode;
    exit;
    }

    $internalfields = array ("submit", "reset", "send", "captcha_code");
    $message .= $eol;
    $message .= "IP Address : ";
    $message .= $_SERVER['REMOTE_ADDR'];
    $message .= $eol;
    foreach ($_POST as $key => $value)
    {
    if (!in_array(strtolower($key), $internalfields))
    {
    if (!is_array($value))
    {
    $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
    }
    else
    {
    $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
    }
    }
    }

    $body = 'This is a multi-part message in MIME format.'.$eol.$eol;
    $body .= '--'.$boundary.$eol;
    $body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
    $body .= 'Content-Transfer-Encoding: 8bit'.$eol;
    $body .= $eol.stripslashes($message).$eol;
    if (!empty($_FILES))
    {
    foreach ($_FILES as $key => $value)
    {
    if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize)
    {
    $body .= '--'.$boundary.$eol;
    $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
    $body .= 'Content-Transfer-Encoding: base64'.$eol;
    $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
    $body .= $eol.chunk_split(base64_encode(file_get_contents($ _FILES[$key]['tmp_name']))).$eol;
    }
    }
    }
    $body .= '--'.$boundary.'--'.$eol;
    mail($mailto, $subject, $body, $header);
    $autoresponder_header = 'From: '.$autoresponder_from.$eol;
    $autoresponder_header .= 'Reply-To: '.$autoresponder_from.$eol;
    $autoresponder_header .= 'MIME-Version: 1.0'.$eol;
    $autoresponder_header .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
    $autoresponder_header .= 'Content-Transfer-Encoding: 8bit'.$eol;
    $autoresponder_header .= 'X-Mailer: PHP v'.phpversion().$eol;
    mail($mailfrom, $autoresponder_subject, $autoresponder_message, $autoresponder_header);
    header('Location: '.$success_url);
    exit;
    }
    ?>

    Per inserire il numero chiuso non saprei da dove iniziare, qualcuno può darmi una mano
    Grazie
    ada50

  2. #2

    Re: Aiuto form iscrizione a numero chiuso

    Originariamente inviato da ada50
    Di php ammetto di saperne quasi niente
    ...
    Per inserire il numero chiuso non saprei da dove iniziare, qualcuno può darmi una mano
    Grazie
    http://php.html.it/guide/leggi/99/guida-php-di-base/
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  3. #3
    Utente di HTML.it L'avatar di homerbit
    Registrato dal
    Dec 2005
    residenza
    Roma
    Messaggi
    1,380
    potresti creare un file "contatore" (oppure appoggiarti al file che già utilizzi) che si autoincrementa di uno ogni qualvolta un utente si registra.
    Al raggiungimento del 21esimo utente questo verrà reinderizzato su una pagina di messaggio e non riceverà la mail. (il controllo sul contatore andrà ovviamente fatto a monte della funzione mail() )
    If you think your users are idiots, only idiots will use it. DropBox

  4. #4
    Utente di HTML.it L'avatar di ada50
    Registrato dal
    Aug 2009
    Messaggi
    27
    Grazie Manuelandro
    Ci avevo pensato ma come ho detto non saprei da dove cominciare con l'integrazione sto cercando uno script per un semplice contatore e poi comicerò le prove e aggiornerò il tread
    ada50

  5. #5
    Utente di HTML.it L'avatar di ada50
    Registrato dal
    Aug 2009
    Messaggi
    27
    Ciao homerbit ammetto l'ignoranza ma non saprei da dove cominciare ad inserire l'autoincrementazione al file che ho postato
    ada50

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 © 2024 vBulletin Solutions, Inc. All rights reserved.