Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 29
  1. #1

    FORM personalizzato semplice in php

    Un saluto a tutti, sono NUOVA del forum e spero di trovarmi bene.

    Ho bisogno del vostro aiuto , premetto che conosco abbastanza bene html e sto studiando il php, ma da autodidatta, sto creando un form, l'ho creato con DREAMWEAVER, ho già fatto le prove con form semplici e lo spazio web comprato accetta file in php ma quello che da me creato NON funziona e ho bisogno di capire dove è l'errore/i.

    INCOLLO il codice del form nella pagina SEND_INFO.PHP <form action="http://www.mio dominio.it/send_info.php" method="post" enctype="multipart/form-data" name="INFO - informazioni generali" id="INFO - Titolo del sito">



    Or Compile this form</p>


    (I dati con l’asterisco sono obbligatori)</p>


    *First
    <input name="first" type="text" id="first" maxlength="30">
    *Last
    <input name="last" type="text" id="last" maxlength="10">
    </p>


    Address
    <input name="address" type="text" id="address" value="" size="40" maxlength="50">
    N.
    <input name="number" type="text" id="number" maxlength="5">
    </p>


    City
    <input name="city" type="text" id="city" maxlength="20">
    State
    <input name="state" type="text" id="state" maxlength="3">
    </p>


    *Email
    <input name="email" type="text" id="email" maxlength="50">
    *Website
    <input name="website" type="text" id="website" maxlength="50">




    *Request</p>



    <textarea name="request" cols="60" rows="10" wrap="VIRTUAL" id="request"></textarea>
    </p>



    <input name="reset " type="reset" id="reset " value="reset">
    </p>


    </p>



    <input name="send" type="submit" id="send" value="send">
    </p>


    (In conformit&agrave; al D. Lgs 196/2003 per la Privacy in vigore
    dal 1 Gennaio 2003, vi chiediamo di compilare il seguente modulo e di
    spuntare la casella per dare il consenso all’utilizzo dei vostri
    dati personali.
    </p>


    Vi verr&agrave; recapitata nel giro di qualche istante una mail
    presso l’indirizzo email che avrete inserito.
    </p>


    Per l'autenticazione della procedura di consenso, cliccare sul
    codice di attivazione che troverete nella mail.

    I dati con l’asterisco sono obbligatori.)
    </p>


    </p>
    </form>

  2. #2

    pagina send_info.php

    Poi aggiungo il codice della pagina SEND_INFO.php

    Fate conto che ho modificato i miei dati sensibili, ovvero la mia email e il nome del sito, che ancora non è online.

    Grazie per chi mi potrà aiutare a far funzionare questo modulo. <?php
    if(isset($_POST['email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "info@miodominio.com"; $email_subject = "Info - INFO ";
    function died($error) {
    // your error code can go here
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    echo "These errors appear below.

    "; echo $error."

    ";
    echo "Please go back and fix these errors.

    ";
    die(); }


    // validation expected data exists

    if(!isset($_POST['first']) ||
    !isset($_POST['last']) ||
    !isset($_POST['address']) ||
    !isset($_POST['number']) ||
    !isset($_POST['city']) ||
    !isset($_POST['state']) ||
    !isset($_POST['email']) ||
    !isset($_POST['website']) ||
    !isset($_POST['request'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); }

    $first = $_POST['first']; // required
    $last = $_POST['last']; // required
    $address = $_POST['address']; // not required
    $number = $_POST['number']; // not required
    $city = $_POST['city']; // not required
    $state = $_POST['state']; // not required
    $email = $_POST['email']; // required
    $website = $_POST['website']; // required
    $request = $_POST['request']; // required

    $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.
    '; }
    $string_exp = "^[a-z .'-]+$"; if(!eregi($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.
    '; } if(!eregi($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.
    '; } if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.
    '; } if(strlen($error_message) > 0) { died($error_message); }





    $email_message .= "first: ".clean_string($first)."\n";
    $email_message .= "last : ".clean_string($last)."\n";
    $email_message .= "address: ".clean_string($address)."\n";
    $email_message .= "number: ".clean_string($number)."\n";
    $email_message .= "city: ".clean_string($city)."\n";
    $email_message .= "state: ".clean_string($state)."\n";
    $email_message .= "email: ".clean_string($email)."\n";
    $email_message .= "request: ".clean_string($request)."\n";


    // create email headers

    $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?>



    <body background="images/collection_images/sfondo_orange_1000_20_jpg.jpg">
    <div align="center"><font color="#FFFFFF"><font color="#000000" size="6">Thank
    you for contacting us. We will be in touch with you very soon</font>
    </font><font color="#000000" size="6">.</font>
    <?php } ?>
    </div>
    </html>

  3. #3
    Utente di HTML.it L'avatar di DjBart
    Registrato dal
    Jan 2009
    Messaggi
    346
    Ciao
    Ti da qualche errore specifico ?

  4. #4
    Si lo stavo per postare ma mi è andata via la corrente ...ecco l'errore (fate conto che ho immesso dati miei veritieri:

    We are very sorry, but there were error(s) found with the form you submitted. These errors appear below.

    The Email Address you entered does not appear to be valid.
    The First Name you entered does not appear to be valid.
    The Last Name you entered does not appear to be valid.
    The Comments you entered do not appear to be valid.


    Please go back and fix these errors.



    Avrete notato la parola Comments che è una stringa che non ho nel form che ho creato, in quanto mi sono auto-aiutata attraverso un link di codici di un free form...purtroppo NON riesco a personalizzare in send_info.php il codice di errore...

    Resto in attesa, grazie davvero.

  5. #5
    Utente di HTML.it L'avatar di las
    Registrato dal
    Apr 2002
    Messaggi
    1,221
    non è un errore, lo script sta funzionando correttamente, è solo che non riconosce come corretti i dati inseriti nel form, stai inserando una email formalmente corretta? nel nome e cognome inserisci solo caratteri?

    per eliminare il controllo su Comments ti basta cancellare questa parte di codice:

    Codice PHP:
    if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.
    '
    ; } 

  6. #6
    certo, ho inserito il mio nome, cognome e la mia email....e NON funziona...

    vado a cancellare quella stringa dei comments...

    ....,a per il resto sono punto e a capo...stavo pensando, per farlo funzionare, o elimino il comando degli errori ?
    però volevo lasciarla questa cosa per eventuali spam...


    cosa posso fare ?

    puoi gentilmente riprovare ?

    veramente ho fatto più prove ma mi dice sempre quella cosa.

    PS: posso postare il link del sito dove ho preso il codice ?

  7. #7
    Utente di HTML.it L'avatar di las
    Registrato dal
    Apr 2002
    Messaggi
    1,221
    prova a sostituire con questo:

    Codice PHP:
    $error_message ""$email_exp "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.
    '
    ; }
    $string_exp "^[a-z .'-]+$"; if(!eregi($string_exp,$first)) {
    $error_message .= 'The First Name you entered does not appear to be valid.
    '
    ; } if(!eregi($string_exp,$last)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.
    '
    ; } if(strlen($comments) < 2
    il problema è che nelle funzioni di controllo andava a guardare variabili che non esistevano, ad esempio il nome veniva definito solo first:

    $first = $_POST['first']; // required

    ma poi quando lo controllava per vedere se erano presenti errori lo chimava $first_name che era una variabile vuota e quindi dava sempre errore.

  8. #8
    1) Ho fatto le modifiche e ora mi da questo errore :

    Grazie per chi mi potrà aiutare a far funzionare questo modulo.
    Fatal error: Call to undefined function clean_string() in D:\Inetpub\webs\miodominio\send_info.php on line 88


    2)poi ho una domanda più semplice, possono stare tre form in un'unica pagina ?

    ovviamente per OGNI form ha la sua pagina con il codice simile a send_info.php

  9. #9
    Perchè non hai definito nessuna funzione "clean_string"...

    Certo puoi mettere quanti form vuoi in una pagina

    <form method="post" action="pagina1.php">
    <input type="text" name="nome" />
    </form>

    <form method="post" action="pagina2.php">
    <input type="text" name="nome" />
    </form>

    <form method="post" action="pagina3.php">
    <input type="text" name="nome" />
    </form>

  10. #10
    Originariamente inviato da damy11
    Perchè non hai definito nessuna funzione "clean_string"...

    ciao grazie anche a te per il tuo aiuto,

    ....ah ok e cosa di devo mettere ?


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.