Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2006
    Messaggi
    26

    Mail e aggiornamento Mysql da form

    Ho creato un form di dati che modifica campi in Mysql.
    L'obiettivo è:
    una volta che invio i dati mi deve generare la mail...

    Il codice per creare la mail funziona, ma il problema è che invia 2 mail...
    1. All'apertura del form (non deve inoltrare nulla)
    2. Nel momento in cui invio i dati (è la mail corretta)

    Grazie per la collaborazione

    Ciao

  2. #2
    posta il codice....


  3. #3
    allora al inizio della pagina tu controlli un valore sentinella.
    esempio:


    Codice PHP:
    ###### inizio pagina ######
    <?
    if($_GET['azione']=='manda'){

    // codice per mandare la mail


    }
    ?>

    <html>
    <body>
    <form action=<? echo $_SERVER['PHP_SELF']; ?> method=get>
    <input type=hidden name=azione value=manda>

    ....
    ....
    ....

    </form>
    </body>
    </html>
    se il valore della variabile sentinella 'azione' non è 'manda',
    non ti manda la mail.
    quando esegui il form mandi la variabile 'azione' con valore 'manda'.
    al reload la pagina manda la mail con le info dal form.

    Per ciò,
    all'apertura non invia nulla
    quando invii i dati la mail va.

    Spero d'aver aiutato

  4. #4
    Utente di HTML.it
    Registrato dal
    Mar 2006
    Messaggi
    26
    Adesso non mi manda due mail... 1 sola, ma non mi aggiorna il database e non va nella pagina dove dovrebbe andare!!!

    Ti invio il codice...

    Help!!!

    <?php require_once('connessione.php');
    include('common.php');
    $user_data = auth_check_user();
    extract($user_data);
    ?>
    <?php
    $data=(date("d/m/Y"));
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
    $updateSQL = sprintf("UPDATE mio_basket SET pippo_ans_date=%s, pippo_ans_user=%s, pippo_ans=%s WHERE id_basket=%s",
    GetSQLValueString($_POST['pippo_ans_date'], "text"),
    GetSQLValueString($_POST['pippo_ans_user'], "text"),
    GetSQLValueString($_POST['pippo_ans'], "text"),
    GetSQLValueString($_POST['id_basket'], "text"));

    mysql_select_db($database_crt, $crt);
    $Result1 = mysql_query($updateSQL, $crt) or die(mysql_error());

    $updateGoTo = "mio_pippo.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $updateGoTo));
    }
    $pippo = $user_name;
    mysql_select_db($database_crt, $crt);
    $query_Recordset1 = "SELECT * FROM mio_basket WHERE id_basket = '$id_riga'";
    $Recordset1 = mysql_query($query_Recordset1, $crt) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);

    mysql_select_db($database_crt, $crt);
    $query_Recordset2 = "SELECT * FROM users WHERE user_name = '$user_name'";
    $Recordset2 = mysql_query($query_Recordset2, $crt) or die(mysql_error());
    $row_Recordset2 = mysql_fetch_assoc($Recordset2);
    $totalRows_Recordset2 = mysql_num_rows($Recordset2);

    $inviare_a = $row_Recordset1['responsanile'];

    mysql_select_db($database_crt, $crt);
    $query_Recordset3 = "SELECT * FROM users WHERE user_name = '$inviare_a'";
    $Recordset3 = mysql_query($query_Recordset3, $crt) or die(mysql_error());
    $row_Recordset3 = mysql_fetch_assoc($Recordset3);
    $totalRows_Recordset3 = mysql_num_rows($Recordset3);
    ?>
    <?
    if($_GET['azione']=='manda'){
    $stato = $row_Recordset1['stato'];
    $subject = "eRC - Avanzamento attività CRT Proposta $stato : $id_riga";
    $email = $row_Recordset2['user_mail'];
    $descrizione = $row_Recordset1['descrizione'];
    $message = "Descrizione: $descrizione - Risposta pippo: $pippo_ans";
    $to = $row_Recordset3['user_mail'];
    mail($to, $subject, $message, "From: $user_name <$email>");
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>| eRC | - Costs Reduction -</title>
    <script language="JavaScript" type="text/JavaScript">
    <!--


    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    //-->
    </script>
    <style type="text/css">
    <!--
    body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #000000;
    }
    body {
    background-color: #FFFFFF;
    }
    a:link {
    text-decoration: none;
    }
    a:visited {
    text-decoration: none;
    }
    a:hover {
    text-decoration: underline;
    color: #000000;
    }
    a:active {
    text-decoration: none;
    color: #000000;
    }
    .Stile1 {
    color: #000000;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 21px;
    font-weight: bold;
    }
    .Stile3 {
    color: #000000;
    font-weight: bold;
    }
    -->
    </style>
    </head>
    <body onLoad="MM_preloadImages('../open.PNG')">
    <table width="740" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr align="center" valign="middle">
    <td colspan="5" align="right">[img]immagini/logo.PNG[/img]</td>
    </tr>
    <tr align="center" valign="middle">
    <td colspan="5" align="right"><span class="Stile1">Sistema di gestione attività</span></td>
    </tr>
    <tr>
    <td colspan="5"></td>
    </tr>
    <tr>
    <td colspan="5" align="right" valign="middle"><?php
    echo $user_name;
    ?>
    <style type="text/css">
    <!--
    body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #000000;
    }
    body {
    background-color: #FFFFFF;
    }
    a:link {
    color: #000000;
    }
    a:visited {
    color: #000000;
    }
    a:hover {
    color: #000000;
    }
    a:active {
    color: #000000;
    }
    -->
    </style>


    home - Richieste/Risposte pippo - Risposta pippo</td>
    </tr>
    <tr>
    <td colspan="5"></td>
    </tr>
    <tr>
    <td colspan="5"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
    <tr>
    <td>
    <form name="form1" action=<?php echo $editFormAction; ?> method="get">
    <input type="hidden" name="azione" value="manda">
    <table width="100%" align="center">
    <tr valign="baseline">
    <td align="right" valign="middle" nowrap>ID</td>
    <td align="left" valign="middle"><?php echo $row_Recordset1['stato']; ?>: <?php echo $row_Recordset1['id_basket']; ?></td>
    </tr>
    <tr valign="baseline">
    <td align="right" valign="middle" nowrap>Codice: <?php echo $row_Recordset1['ptf']; ?></td>
    <td align="left" valign="middle">Modello: <?php echo $row_Recordset1['modello']; ?></td>
    </tr>
    <tr valign="baseline">
    <td align="right" valign="middle" nowrap>Descrizione Proposta:</td>
    <td align="left" valign="middle"><?php echo $row_Recordset1['descrizione']; ?></td>
    </tr>
    <tr valign="baseline">
    <td align="right" valign="top" nowrap>Richiesta pippo :</td>
    <td align="left" valign="middle">Data: <?php echo $row_Recordset1['pippo_ask_date']; ?>

    Descrizione Richiesta: <?php echo $row_Recordset1['pippo_ask']; ?></td>
    </tr>
    <tr valign="baseline">
    <td align="right" valign="middle" nowrap>Data:</td>
    <td align="left" valign="middle"><input name="pippo_ans_date" type="text" value="<?php echo $data; ?>" size="25" readonly="true"></td>
    </tr>
    <tr valign="baseline">
    <td align="right" valign="middle" nowrap>Responsabile:</td>
    <td align="left" valign="top"><input name="pippo_ans_user" type="text" value="<?php echo $user_name; ?>" size="25" readonly="true"></td>
    </tr>
    <tr valign="baseline">
    <td width="33%" align="right" valign="top" nowrap>Risposta pippo :</td>
    <td align="left" valign="top"><textarea name="pippo_ans" cols="25" rows="10"><?php echo $row_Recordset1['pippo_ans']; ?></textarea></td>
    </tr>
    <tr align="center" valign="middle">
    <td colspan="2" nowrap><input type="submit" value="Modifica"></td>
    </tr>
    </table>
    <input type="hidden" name="MM_update" value="form1">
    <input type="hidden" name="id_basket" value="<?php echo $row_Recordset1['id_basket']; ?>">
    </form></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <?php
    mysql_free_result($Recordset1);

    mysql_free_result($Recordset2);

    mysql_free_result($Recordset3);
    ?>

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.