Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Form per allega CV

  1. #1

    Form per allega CV

    Ciao a tutti sto sbattendo la testa da giorni per un form in cui devo allegare un cv. Ho provato in tutti i modi ma non mi riesce. Se vi posto il codice potete gentilmente darmi una mano poichè ok il PHP ma non sono competente più di tanto. In pratica è un semplice form con nome, cognome, telefono, email, ecc ma siccome nel file php ci sono gli array come faccio a fare il tutto? Vi posto il form ed il file php. Se mi aiutate ve ne sono grato. GRAZIE!!

    <form id="contact-form" method="post" action="contatti.php" role="form">
    <div class="row">
    <div class="span4 form-group">
    <label for="form_name"></label>
    <input id="form_name" type="text" name="name" class="input-block-level" placeholder="Nome e cognome *" required="required" data-error="Firstname is required.">
    <div class="validation"></div>
    </div>


    <div class="span4 form-group">
    <label for="form_lastname"></label>
    <input id="form_lastname" type="text" name="azienda" class="input-block-level" placeholder="Azienda *" required="required" data-error="Lastname is required.">
    <div class="validation"></div>
    </div>
    <div class="span4 form-group">
    <label for="form_email"></label>
    <input id="form_email" type="email" name="email" class="input-block-level" placeholder="Email *" required="required" data-error="Valid email is required.">
    <div class="validation"></div>
    </div>
    <div class="span4 form-group">
    <label for="form_phone"></label>
    <input id="form_phone" type="tel" name="phone" class="input-block-level" placeholder="Telefono *">
    <div class="validation"></div>
    </div>


    <div class="span8 form-group">
    <textarea class="input-block-level" name="message" rows="5" data-rule="required" data-msg="Please write something for us" placeholder="Message"></textarea>
    <div class="validation"></div>
    <div class="text-center">
    <input name="privacy" id="privacy" type="radio" value="si" /> Autorizzo trattamento
    <a href="privacy.htm"> Privacy Policy </a></p>
    <input type="submit" class="btn btn-theme" value="Invia Messaggio">
    </div>
    </div>
    </div>
    </form>


    <?php
    /*
    * CONFIGURE EVERYTHING HERE
    */


    // an email address that will be in the From field of the email.
    $from = 'Preventivo dal sito <info@irmap.it>';


    // an email address that will receive the email with the output of the form
    $sendTo = 'Messaggio dal sito <info@irmap.it>';


    // subject of the email
    $subject = 'Messaggio dal sito';


    // form field names and their translations.
    // array variable name => Text to appear in the email
    $fields = array('name' => 'Name', 'azienda' => 'Azienda', 'phone' => 'Phone', 'email' => 'Email', 'message' => 'Message', 'privacy' => 'Privacy');


    // message that will be displayed when everything is OK
    $okMessage = 'Il tuo messaggio è stato inviato correttamente. Verrai contattato al più presto. Grazie!';


    // If something goes wrong, we will display this message.
    $errorMessage = 'There was an error while submitting the form. Please try again later';


    /*
    * LET'S DO THE SENDING
    */


    // if you are not debugging and don't need error reporting, turn this off by error_reporting(0);
    error_reporting(E_ALL & ~E_NOTICE);


    if(!$_POST['privacy']){ //Non selezionata
    echo 'Attenzione! Non hai accettato la Privacy.';
    return;
    }


    try
    {


    if(count($_POST) == 0) throw new \Exception('Form is empty');

    $emailText = "You have a new message from your contact form\n=============================\n";


    foreach ($_POST as $key => $value) {
    // If the field exists in the $fields array, include it in the email
    if (isset($fields[$key])) {
    $emailText .= "$fields[$key]: $value\n";
    }
    }


    // All the neccessary headers for the email.
    $headers = array('Content-Type: text/plain; charset="UTF-8";',
    'From: ' . $from,
    'Reply-To: ' . $from,
    'Return-Path: ' . $from,
    );

    // Send email
    mail($sendTo, $subject, $emailText, implode("\n", $headers));


    $responseArray = array('type' => 'success', 'message' => $okMessage);
    }
    catch (\Exception $e)
    {
    $responseArray = array('type' => 'danger', 'message' => $errorMessage);
    }




    // if requested by AJAX request return JSON response
    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    $encoded = json_encode($responseArray);


    header('Content-Type: application/json');


    echo $encoded;
    }
    // else just display the message
    else {
    echo $responseArray['message'];
    }


    ?>

  2. #2
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,445
    Dovresti almeno spiegare COSA non ti riesce.
    Ti da un errore? Non fa ciò che ti aspetti? In tal caso che comportamento errato ha?

    Nel titolo scrivi che il form serve per allegare il CV, ma non mi pare di vedere codice per allegare file.

    Hai fatto copia/incolla di un qualche tutorial ed hai provato ad adeguarlo al tuo form, vero? E' un pastrocchio indicibile il codice che hai postato.

  3. #3
    [QUOTE=Alhazred;25520648]Dovresti almeno spiegare COSA non ti riesce.
    Ti da un errore? Non fa ciò che ti aspetti? In tal caso che comportamento errato ha?

    Nel titolo scrivi che il form serve per allegare il CV, ma non mi pare di vedere codice per allegare file.

    Hai fatto copia/incolla di un qualche tutorial ed hai provato ad adeguarlo al tuo form, vero? E' un pastrocchio indicibile il codice che hai postaro

    Dunque, questo è un codice che avevo ma perché è un pastrocchio scusa? È un semplice form di contatti.
    comunque ho provato a modificarlo nella parte in cui voglio che mi alleghi un file pdf ma non riuscendo né a capire né a sapere dove copiare la parte di codice dell’allega file al mio ci ho rinunciato e chiedo come debbo fare, grazie.

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.