Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di justix
    Registrato dal
    Feb 2005
    Messaggi
    103

    onsubmit email autoresponse?

    Ciao a tutti, premetto che non mastico di PHP e Java, riesco a capire alcune funzioni ma sono lontano dal risolvere situazioni come la seguente, vorrei sapere se fosse possibile poter inserire una autoresponse email x notificare l'avvenuta iscrizione da form esistente, la form da me acquistata non aveva pero' i campi obbligatori e chiunque poteva caxxrare riempiendo l'amministrazione di form incompleti e inesistenti (nemmeno il campo email lo era..bah) ma ho risolto brillantemente usando uno script java che controlla se i campi definiti come obbligatori siano riempiti oppure un bel messaggio di errore.

    Required field(s) validation script:
    <script language="JavaScript">
    <!--
    function formCheck(formobj){
    // Enter name of mandatory fields
    var fieldRequired = Array("user", "email");
    // Enter field description to appear in the dialog box
    var fieldDescription = Array("username", "email");
    // dialog message
    var alertMsg = "Please complete the following fields:\n";

    var l_Msg = alertMsg.length;

    for (var i = 0; i < fieldRequired.length; i++){
    var obj = formobj.elements[fieldRequired[i]];
    if (obj){
    switch(obj.type){
    case "select-one":
    if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
    alertMsg += " - " + fieldDescription[i] + "\n";
    }
    break;
    case "select-multiple":
    if (obj.selectedIndex == -1){
    alertMsg += " - " + fieldDescription[i] + "\n";
    }
    break;
    case "text":
    case "textarea":
    if (obj.value == "" || obj.value == null){
    alertMsg += " - " + fieldDescription[i] + "\n";
    }
    break;
    default:
    }
    if (obj.type == undefined){
    var blnchecked = false;
    for (var j = 0; j < obj.length; j++){
    if (obj[j].checked){
    blnchecked = true;
    }
    }
    if (!blnchecked){
    alertMsg += " - " + fieldDescription[i] + "\n";
    }
    }
    }
    }

    if (alertMsg.length == l_Msg){
    return true;
    }else{
    alert(alertMsg);
    return false;
    }
    }
    // -->
    </script>

    <form name="formcheck" onsubmit="return formCheck(this);">
    <input type=hidden name=complete value=1>
    <div align='center'><center><table border='0' width='100%'>
    <tr>
    <td width='40%' align='right'>Username<font color="#FF0000">*</font>: </td><td width='60%'><input type='text' name='user' size='20' maxlength="200"></td></tr>
    <tr>
    <td width='40%' align='right'>Full Name<font color="#FF0000">*</font>: </td><td width='60%'><input type='text' name='name' size='50' maxlength="200"></td></tr>
    <tr>
    <td align='right'>Business Name<font color="#FF0000">*</font></td>
    <td width='60%'><input type='text' name='bizname' size='50' maxlength="100"></td>
    </tr>
    <tr><td width='40%' align='right'>Street Address: </td><td width='60%'><input type='text' name='add1' size='32' maxlength="60"></td></tr>
    <tr><td width='40%' align='right'> </td><td width='60%'><input type='text' name='add2' size='32' maxlength="60"></td></tr>
    <tr><td width='40%' align='right'>City: </td><td width='60%'><input type='text' name='city' size='16' maxlength="18"></td></tr>
    <tr><td width='40%' align='right'>State/Province: </td><td width='60%'><input type='text' name='state' size='16' maxlength="60"></td></tr>
    <tr>
    <td width='40%' align='right'>Zip / Postcode: </td><td width='60%'><input type='text' name='zip' size='6' maxlength="10"></td></tr>
    <tr><td width='40%' align='right'>Country: </td><td width='60%'><input type='text' name='country' size='16' maxlength="200"></td></tr>
    <tr><td width='40%' align='right'>Home Phone: </td><td width='60%'><input type='text' name='homephone' size='16' maxlength="20"></td></tr>
    <tr>
    <td width='40%' align='right'>Email Address<font color="#FF0000">*</font>: </td><td width='60%'><input type='text' name='email' size='20' maxlength="200"></td></tr>
    <tr>
    <td width='40%' align='right'>Alternative Email Address: </td>
    <td width='60%'><input type='text' name='Aemail' size='20' maxlength="200"></td></tr>
    <tr>
    <td width='40%' align='right'>Short Business Description: </td><td width='60%'><input type='text' name='bizdesc' size='60' maxlength="200"></td></tr>
    <tr>
    <td width='40%' align='right'>Business Phone N.: </td><td width='60%'><input type='text' name='bizphone' size='16' maxlength="15"></td></tr>
    <tr><td width='40%' align='right'> </td><td width='60%'><input type='submit' value='Submit'></td></tr>
    </table>
    </form>
    A brilliant plan with just one small problem - it was bollocks!

  2. #2
    io direi che puoi usare questa funzione php nel momento in cui il form viene convalidato

    mail($indirizzo,$oggetto,$messaggio);

    mettendo nelle variabili i dati che hai appena ottenuto dal form.

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.