invio email al db
-
salve gente ho un problema che spero mi aiutiate a risolvere io voglio salvare le mail nel database io ho usato due files uno config e uno mailform
posto il mail form.php
<? include 'config.php'; $adminaddress = "[email protected]"; $siteaddress ="http://www.actionscriptnews.com"; $sitename = "actionscriptnews.com"; //No need to change anything below ... // Gets the date and time from your server $date = date("m/d/Y H:i:s"); // Gets the IP Address if ($REMOTE_ADDR == "") $ip = "no ip"; else $ip = getHostByAddr($REMOTE_ADDR); // Gets the POST Headers - the Flash variables $action = $HTTP_POST_VARS['action'] ; $email = $HTTP_POST_VARS['email'] ; $name = $HTTP_POST_VARS['name'] ; $cognome = $HTTP_POST_VARS['cognome'] ; $comments = $HTTP_POST_VARS['comments'] ; $telefono = $HTTP_POST_VARS['telefono'] ; $oggetto = $HTTP_POST_VARS['oggetto'] ; //Process the form data! // and send the information collected in the Flash form to Your nominated email address if ($action == "send") { //Innanzitutto controlliamo la var.le name: $controllo = check_email($email); if ($controllo != "OK") { echo $controllo; //Qui potresti anche far visualizzare una cosa del genere: echo "<BR><A HREF=\"http://www.marikweb.com/homeita/\">Ritorna alla registrazione</A>"; } else { //Ora inseriamo i dati nel DB. //Ovviamente devi creare una tabella in cui inserire i dati ke passi con il post. $link_db = mysql_connect($CONFIG['host'],$CONFIG['user'],$CONFIG['pass']); mysql_select_db($CONFIG['dbname']); $sql_insert = "INSERT INTO contact (name,cognome,email,telefono,oggetto,comments) VALUES('$name','$cognome','$email','$telefono','$oggetto','$comments')"; if (mysql_query($sql_insert)) { echo "OK RIGA INSERITA <br />"; } else { die(mysql_error()); } mysql_close($link_db); // mail ("$adminaddress","informazioni", "Il visitatore ha lasciato le seguenti informazioni \n Name: $name Email: $email\n Telefono: $telefono Messaggio: ------------------------------ $comments Logged Info : ------------------------------ Using: $HTTP_USER_AGENT Hostname: $ip IP address: $REMOTE_ADDR Date/Time: $date","FROM:$email" ) ; //This sends a confirmation to your visitor mail ("$email","Re:", "Salve $name,\n abbiamo ricevuto il suo messaggio e presto sarà contattato.\n Saluti dallo Staff di $sitename By $siteaddress","FROM:$adminaddress ") ; //Confirmation is sent back to the Flash form that the process is complete $sendresult = "Thank you. You will receive a confirmation email shortly."; $send_answer = "answer="; $send_answer .= rawurlencode($sendresult); echo $send_answer; } } ?><?php $CONFIG['host'] = "localhost"; $CONFIG['user'] = "rocco"; $CONFIG['pass'] = "maurizio"; $CONFIG['dbname'] = "user35512_7777"; $CONFIG['expire'] = 60; $CONFIG['regexpire'] = 24; //in ore $CONFIG['expire'] = 60; $CONFIG['regexpire'] = 24; //in ore $CONFIG['check_table'] = array( "name" => "check_global", "email" => "check_global" ); function check_email($value) { global $CONFIG; $value = trim($value); if (($value == "")) { echo"Il campo non può essere lasciato vuoto"; } else{ $query = @mysql_query("SELECT id FROM contact WHERE email='$value'")or die("Errore nella query"); if (@mysql_num_rows($query) != 0) return "Email già utilizzata"; else return"OK"; } } //-------------- define('AUTH_LOGGED', 99); define('AUTH_NOT_LOGGED', 100); define('AUTH_USE_COOKIE', 101); define('AUTH_USE_LINK', 103); define('AUTH_INVALID_PARAMS', 104); define('AUTH_LOGEDD_IN', 105); define('AUTH_FAILED', 106); define('REG_ERRORS', 107); define('REG_SUCCESS', 108); define('REG_FAILED', 109); $conn = @mysql_connect($CONFIG['host'], $CONFIG['user'], $CONFIG['pass']) or die('Impossibile stabilire una connessione'); @mysql_select_db($CONFIG['dbname']) or die("Errore nel DB"); ?> tabella################################# [CODE] CREATE TABLE `contact` ( `id` int(40) NOT NULL default '0', `date` datetime NOT NULL default '0000-00-00 00:00:00', `name` varchar(50) NOT NULL default '', `cognome` varchar(50) NOT NULL default '', `email` varchar(100) NOT NULL default '', `telefono` varchar(50) NOT NULL default '', `oggetto` varchar(100) NOT NULL default '', `comments` text NOT NULL, `ip` varchar(15) NOT NULL default '', PRIMARY KEY (`id`) ) [/CODE] -
-
-
-
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi