![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 55 Pomógł: 0 Dołączył: 21.09.2007 Skąd: Mielec Ostrzeżenie: (0%) ![]() ![]() |
Witam,
Wiem, że problem przewijał się już na forum, ale mam tutaj konkretną budowę skryptu: Otóż chcę zrobić, aby w jednym formularzu było zapisywanie i wypisywanie do newslettera naraz. A to moje wypociny, ale niestety nie działają jak trzeba: Kod <form name="txtlist" action="./index.php" target="txtlist" method="get" onsubmit="javascript:window.open('','txtlist','width=300,height=150,toolbar=no,status=no,resizable=no')">
<table border="0" cellpadding="4" cellspacing="0" bgcolor="#efefef" style="border: #dedede 3px double;"> <tr><td> <input type="hidden" name="type" value="sub"/> <input type="hidden" name="type" value="unsub"/> <input type="text" name="email" value="email address" size="20" maxlength="100" onfocus="if (this.value=='email address') this.value=''" onblur="if (this.value=='') this.value='email address'"/> <input type="submit" name="sub" value="subscribe"/> <input type="submit" name="unsub" value="unsubscribe"/> </td></tr> </table> Ten post edytował kamil881 29.01.2009, 12:51:28 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 55 Pomógł: 0 Dołączył: 21.09.2007 Skąd: Mielec Ostrzeżenie: (0%) ![]() ![]() |
To jest plik index.php
Dodać to tu gdzieś po prostu? Kod <?
require('config.inc.php'); require('functions.inc.php'); // Max execution time of script. This does not include sleep time, so only restricts time // allowed for mailing. set_time_limit(3600); $type = $_GET['type']; $addr = stripslashes(urldecode($_GET['email'])); if ($type == 'sub') { // subscribe address. Actually, all it does is send the confirmation email if (!preg_match('#^([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+[^\".,?! ])$#i', $addr)) { $err = 'Your email address appears to be invalid.'; } if (!isset($err)) { $f = openfile($cfg['listfile']); $exists = false; while ($item = readitem($f)) { if ($item['addr'] == $addr) {$exists = true;break;} } if ($exists) { $err = 'That address is already subscribed to the list.'; } } if (!isset($err)) { // send confirmation email $headers = 'From: '.$cfg['from']; if ($cfg['headers']) { foreach ($cfg['headers'] as $val) $headers .= "\n".$val; } $headers .= "\n".$cfg['header_plain']; if (!@mail($addr, $cfg['subj_conf'], sprintf($cfg['msg_conf'], '?type=confirm&email='.urlencode($addr)), $headers)) { $err = 'There was an error sending the confirmation email. Please try again later.'; } } if (!isset($err)) { // confirmation sent if (isset($cfg['returnto_conf']) && $cfg['returnto_conf'] != '') { header('Location: '.$cfg['returnto_conf']); } else { printf($cfg['template'], 'Awaiting confirmation', 'An email has been sent to your address, '.$addr.', with a URL you must visit to confirm your subscription.'); } } else { // problem with subscription echoerr($err); } } elseif ($type == 'unsub') { // unsubscribe address $f = openfile($cfg['listfile']); $exists = false; while ($item = readitem($f)) { if ($item['addr'] == $addr) {$exists = true;break;} } if ($exists) { delitem($f, $item['id']); } else { $err = 'That address was not found.'; } if (!isset($err)) { // unsubscribe successful if (isset($cfg['returnto_unsub']) && $cfg['returnto_unsub'] != '') { header('Location: '.$cfg['returnto_unsub']); } else { printf($cfg['template'], 'Unsubscribed', 'Your address, '.$addr.' has successfully been unsubscribed from our mailing list.'); } } else { // problem with unsubscription echoerr($err); } } elseif ($type == 'confirm') { // subscribe a confirmed address if (!preg_match('#^([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+[^\".,?! ])$#i', $addr)) { $err = 'Your email address appears to be invalid. If you are pasting the URL from your confirmation email, make sure the URL wasn\'t split into two lines.'; } if (!isset($err)) { $f = openfile($cfg['listfile']); $exists = false; while ($item = readitem($f)) { if ($item['addr'] == $addr) {$exists = true;break;} } if ($exists) { $err = 'That address is already subscribed to the list.'; } } if (!isset($err)) { // subscribe successful writeitem($f, $addr); if (isset($cfg['returnto_sub']) && $cfg['returnto_sub'] != '') { header('Location: '.$cfg['returnto_sub']); } else { printf($cfg['template'], 'Subscribed', 'Your address, '.$addr.', is now subscribed to our mailing list!'); } } else { // problem with subscription echoerr($err); } } function echoerr($err) { printf($GLOBALS['cfg']['template'], 'Error', '<font color="red">Error: '.$err.'</font>'); } ?> |
|
|
![]() ![]() |
![]() |
Aktualny czas: 4.10.2025 - 00:03 |