- Home
- Categorie
- Coding e Sistemistica
- PHP
- script registrazione email+invio email
-
ok allora andiamo passo passo...
il codice del form è questo:<form method="post">
Tuo nome:<input type="text" name="nome" value="" size="20">
Tua e-mail:<input type="text" name="email" value="Tua e-mail" size="20">
<input type="radio" name="action" value="sub" checked><font size="-1"> Subscribe</font>
<input type="radio" name="action" value="unsub"><font size="-1"> Unsubscribe</font>
<input type="submit" value="submit"></form>come vedi ho aggiunto il campo nome che passa tramite post...
ora il msg di benvenuto viene elaborato sempre nella stessa pagina .. ed il codice in questione è questo:
function send_welcome($email) {
// Send confirmation letter to new subscriber.
global $welcome_msg, $welcome_subject, $list_name, $owner_email, $sig, $version;
$welcome_subject = replace_shortcuts($welcome_subject, $email);
$headers = "From: "$list_name" <$owner_email>\nReply-To: $owner_email\n";
$welcome_msg .= "\n\n$sig";
$welcome_msg = replace_shortcuts($welcome_msg, $email);
mail($email, $welcome_subject, $welcome_msg, $headers);
}in quest codice si deve implementare la varibile $nome. il msg (NO IL SOGGETTO) che arriva alla persona deve essere:
Ciao <nome>,
grazie....... bla bla bla...
-
ci sono delle cose che non vanno:
anzitutto
<input type="submit" value="submit">
qui manca il name e quindi come può lo script riconoscere la variabile submit se non le dai un nome?Quindi devi mettere:
<input type="submit" name="submit" value="submit">Ancora più grave:
<form method="post">
in questo caso manca l'action. Con l'action indichi quale sarà la pagina php incaricata di ricevere le variabili passate dal form ed elaborarle.Se, come dici, la pagina è la stessa in cui è contenuto il form devi mettere:
<form method="post" action= $PHP_SELF>La variabile $nome la recuperi al di fuori della funzione send_welcome e si recupera scrivendo così: $nome = $_POST['nome'];
Infine sostitusici
$welcome_msg .= "\n\n$sig"; con
$welcome_msg = "Ciao " . $nome . ", grazie ....bla bla bla...";e cancella questa riga:
$welcome_msg = replace_shortcuts($welcome_msg, $email);Un modo più semplice di fare le cose, in alternativa, è di leggersi il file README ( = Leggimi ) contenuto nello zip che hai postato. E' molto chiaro e utile.
-
c'è qualcosa che nn mi convince....
allora proviamo (ne approfitto della tua gentilezza) a configurarlo insieme ... se vai quihttp://www.fgtendaggi.it/mail/maillist.php?action=admin
entri nel pannello di controllo ecco i dati:
user
passentrando nell'amministrazione vedi che ci sono varie possibilità:
. mandare un messaggio di benvenuto- mandare un email di conferma registrazione
- ed un messaggio quando l'utente si cancella
ci sono delle varibili:
%list_name% = The name of the list.
%email% = The email address the email is being sent it.
%confirm_url% = URL user must go to to confirm subscription.
%subscribe_url% = URL users go to to resubscribe.
%unsubscribe_url% = URL where user can unsubscribe.che possono essere inserite nel messaggio .....
ora io vorrei scrivere la variabile nome in questo modo ....grazie per il tuo aiuto
-
ho modificato una cosa nella configurazione
devi poi sostituire la funzione send_welcome($email) originale con questa:
function send_welcome($email) {
// Send confirmation letter to new subscriber.
global $welcome_msg, $welcome_subject, $list_name, $owner_email, $sig, $version, $nome;
$welcome_subject = replace_shortcuts($welcome_subject, $email);
$headers = "From: "$list_name" <$owner_email>\nReply-To: $owner_email\nX-Mailer: PHPMailList V$version http://php.warpedweb.net/";
$welcome_msg .= "\n\n$sig";
$welcome_msg = replace_shortcuts($welcome_msg, $email);
$welcome_msg = str_replace("{nome}", $nome, $welcome_msg);
mail($email, $welcome_subject, $welcome_msg, $headers);
}e dovrebbe andare. Fammi sapere
-
ok funziona perfettamente ....
un ultima cosa .... vorrei che nel file dat si registrasse anche il nome oltre all'email .. il codice in questione che apre e chiude il file è questo:function remove_from_list($email) {
// Removes the address from the file.
global $list_file;
$file = @file($list_file);
$success = false;
$fd = @fopen($list_file, "w") or die("<center><b>The list data file could not be opened for writing.</b></center>");
if ($file) {
foreach($file as $address) {
$address = trim($address);
if ($address != $email) fputs($fd, "$address\n");
else $success = true;
}
fclose($fd);
}
return $success;
}function add_to_list($email) {
// Adds the email address to the data file.
global $list_file;
$fd = @fopen($list_file, "a") or die("<center><b>The list data file could not be opened.</b><br>Check the path and permissions.</center>");
fputs($fd, strtolower($email)."\n");
fclose($fd);
return true;
}potresti darmi una mano (che spacciato che sono) anche con questa parte di codice ???
-
per quanto riguarda la scrittura del file ... forse ci sto riuscendo .. allora ecco il codice che ho aggiunto:
function add_to_list($email) {
// Adds the email address to the data file.
$nome = $_POST['nome'];
global $list_file;
$fd = @fopen($list_file, "a") or die("<center><b>The list data file could not be opened.</b><br>Check the path and permissions.</center>");
fputs($fd, strtolower($nome));
fputs($fd, strtolower($email)."\n");
fclose($fd);
return true;
}però cosi il nome e l'email viene attaccato non riesco a dare lo spazio tra le due variabili
-
fai così (in questo modo scriverà, ad esempio: nomeutente - [EMAIL="[email protected]"][email protected][/EMAIL]
function add_to_list($email) {
// Adds the email address to the data file.
$nome = $_POST['nome'];
global $list_file;
$fd = @fopen($list_file, "a") or die("<center><b>The list data file could not be opened.</b><br>Check the path and permissions.</center>");
fputs($fd, strtolower($nome). " - " . strtolower($email)."\n");
fclose($fd);
return true;
}
-
perfetto funziona .. ma c'è un piccolo problem ... quando provo a cancellare l'email tramite Unsubscribe selezionato ... l'email non viene cancellata , ovviamente la funzione :
function remove_from_list($email) {
// Removes the address from the file.
global $list_file;
$file = @file($list_file);
$success = false;
$fd = @fopen($list_file, "w") or die("<center><b>The list data file could not be opened for writing.</b></center>");
if ($file) {
foreach($file as $address) {
$address = trim($address);
if ($address != $email) fputs($fd, "$address\n");
else $success = true;
}
fclose($fd);
}
return $success;
}non riconosce:
nome utente - email
?????????????????????
-
Prova questa soluzione:
function remove_from_list($email) {
// Removes the address from the file.
global $list_file;
$file = @file($list_file);
$success = false;
$fd = @fopen($list_file, "w") or die("<center><b>The list data file could not be opened for writing.</b></center>");
if ($file) {
foreach($file as $address) {
$address2 = trim(substr(stristr($address, "-"),2));
if ($address2 != $email) fputs($fd, "$address\n");
else $success = true;
}
fclose($fd);
}
return $success;
}
-
Ok Tutto Perfetto ... Sei Ingamba... Ci Sentiamo ...
-
è sempre un piacere aiutare le persone riconoscenti!
-
ienavr ho un piccolo problema ... l'email e nomi posso essere registrati continuamente anche già presente nel file list.dat ... il codice in questione dovrebbe essere questo:
[php]
function subscribe($email, $nome, $send_confirm, $send_welcome) {
// Subscribes address to list.
global $list_name;
if (($email == ""))
{
print_subscribe_form();
}
else {
if (!banned($email)) {
if (!on_list($email)) {
if (valid_email($email)) {
if ($send_confirm == "on") {
send_confirm($email);
echo "<h4 align="center">"$nome" Grazie per la tua registrazione a "$list_name".</h4><center>Un e-mail è stata inviata a "$email" asking you to confirm your subscription.<br>Please follow those instructions to complete the process.</center>";
}
else {
if (add_to_list($email)) {
echo "<h4 align="center">"$nome" l'e-mail: "$email" è stata registrata corettamente in "$list_name".</h4>";
if ($send_welcome == "on") {
send_welcome($email);
echo "<br><center>Riceverai a breve un e-mail con le informazioni per scaricare gratuitamente i tuoi due regali, Grazie. <br><br><img src="logo copia ok.png" alt="logo Tendaggi" /><br><br>|<a href="http://www.fgtendaggi.it">Vai alla Home</a>| <a href="http://www.fgtendaggi.it/tende e tendaggi.html"> Visita il sito</a>|</center>";
}
}
}
}
else echo "<h4 align="center">L'indirizzo e-mail: "$email" non è valido.</h4>";
}
else echo "<h4 align="center">L'e-mail: "$email" risulta già nel nostro database.<br> Se vuoi scaricare nuovamente i due regali contattaci a [email protected]</h4> <br><br><img src="logo copia ok.png" alt="logo Tendaggi" /><br><br>|<a href="http://www.fgtendaggi.it">Vai alla Home</a>| <a href="http://www.fgtendaggi.it/tende e tendaggi.html"> Visita il sito</a>|</center>";
}
else echo "<h4 align="center">L'indirizzo e-mail: "$email" è sospeso da "$list_name".</h4>";
}
}
[/php]
ma cosa c'è che non và secondo te????????
-
ciao vincenzo e scusa se non ho risposto prima!
La funzione da cambiare non è subscribe, ma on_list.
Per la precisione devi sostituire questo pezzo di codice:
function on_list($email) {
// Returns true if email address is on list.
global $list_file;
$found = false;
$file = @file($list_file);
if ($file) {
foreach ($file as $address) {
if (trim($address) == trim($email)) {
$found = true;
}
}
}
return $found;
}con questo:
function on_list($email) {
// Returns true if email address is on list.
global $list_file;
$found = false;
$file = @file($list_file);
if ($file) {
foreach ($file as $address) {
if ( trim(substr(stristr($address, "-"),2)) == trim($email)) {
$found = true;
}
}
}
return $found;
}Spero che sia tutto corretto!
Ciao
-
fantastico ... tutto coretto ... sono ripetitivo ma non posso esimermi dal farti i complimenti
-
Ciao a tutti, nn riesco ad accedere all'area amministrazione mi date una mano? nn so configurarlo forse
function admin() {
// Controls the administration options.
global $q, $username, $password, $user, $pass;
if (($user == $username) && ($pass == $password)) {
if ($q == "send_msg") admin_send_msg();
elseif ($q == "send_msg_confirm") admin_send_msg_confirm();
elseif ($q == "write_msg") admin_write_msg();
elseif ($q == "view_subs") admin_view_subs();
elseif ($q == "config") admin_config();
elseif ($q == "add_remove") admin_add_remove();
admin_print_options();
}
else {
if (($username == "MIAUSERNAME") && ($password == "MIA PASSWORD)) admin_print_logon("");
else admin_print_logon("Invalid username and/or password.");
}
}CHE DEVO SCRIVERE IN QUEI CAMPI? GRAZIE RAGAZZI
-
SCUSATE ANCORA, HO UN'ALTRO PROBLEMA..... MA NEI CAMPI
if ($email == "") DEVO METTERE LA EMAIL DEL SITO?function subscribe($email, $nome, $send_confirm, $send_welcome) {
// Subscribes address to list.
global $list_name;
if ($email == "")
{
print_subscribe_form();
}
else {
if (!banned($email)) {
if (!on_list($email)) {
if (valid_email($email)) {
if ($send_confirm == "on") {
send_confirm($email);
echo "<h4 align="center">"$nome" Thank you for subscribing to "$list_name".</h4><center>An email will be sent to "$email" asking you to confirm your subscription.<br>Please follow those instructions to complete the process.</center>";
}
else {
if (add_to_list($email)) {
echo "<h4 align="center">"$nome" The email address: "$email" has been subscribed to "$list_name".</h4>";
if ($send_welcome == "on") {
send_welcome($email);
echo "<br><center>A welcome message will be emailed to you confirming this.</center>";
}
}
}
}
else echo "<h4 align="center">The email address: "$email" does not appear to be valid.</h4>";
}
else echo "<h4 align="center">The email address: "$email" is already subscribed to this list.</h4>";
}
else echo "<h4 align="center">The email address: "$email" has been banned from "$list_name".</h4>";
}
}function unsubscribe($email) {
// Removes email from list if it exists.
global $list_file, $list_name, $send_goodbye;
if ($email == "") {
print_subscribe_form();
}
else {
if (remove_from_list($email)) {
echo "<center><b>The email address: "$email" has been removed from "$list_name".</b>";
if ($send_goodbye == "on") {
send_goodbye($email);
echo "<br>A email confirming this will be sent to "$email".";
}
echo "</center>";
}
else echo "<center><b>The email address: "$email" is not subscribed to "$list_name".</b>";
}
}