Sistema de indicação para múltiplos emails

Publicado por Perfil removido 17/11/2005

[ Hits: 8.275 ]

Download invite.php




Este sistema de indicação permite o envio para mútiplos emails com validações.

  



Esconder código-fonte

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Invite a friend</title>

<script type="text/javascript">

function dropFile(btn){
    if(document.getElementById) {
        tr = btn;
        while (tr.tagName != 'TR') tr = tr.parentNode;
        tr.parentNode.removeChild(tr);
        checkForLast();
    }
}

function addFile(btn){
    if(document.getElementById) {
        tr = btn;
        while (tr.tagName != 'TR') tr = tr.parentNode;
        var idSuffix = Math.round(Math.random()*1000);
        var newTr = tr.parentNode.insertBefore(tr.cloneNode(true),tr.nextSibling);
        thisChilds = newTr.getElementsByTagName('td');
        for (var i = 0; i < thisChilds.length; i++){
            if (thisChilds[i].className == 'header') thisChilds[i].innerHTML = '';
            if (thisChilds[i].className == 'text') thisChilds[i].innerHTML = '';
        }
        checkForLast();
    }
}

function checkForLast(){
    btns = document.getElementsByName('drop');

    for (i = 0; i < btns.length; i++){
        btns[i].disabled = (btns.length == 1) ? true : false;
    }
}

function verify_form(form_invite){

if (form_invite.name_from.value == ""){
alert("Full your name");
form_invite.name_from.focus();
return (false);
}

if (form_invite.email_from.value == ""){
alert("Full your email");
form_invite.email_from.focus();
return (false);
}

return (true);
}


</script>

<style type="text/css">
body {
     margin:20 auto;
     text-align:center;
     font:10px verdana, Arial, Helvetica, sans-serif;
     color:#666;
}

.row_left {
      float:left;
      width:25%;
      margin-top:4px;
      padding:5px;
      text-align:right;
}
.row_right {
      float:left;
      width:60%;
      margin-top:4px;
      padding:0px;
      margin-left:4px;
      text-align:left;
}
.all_screen {
      float:left;
      width:90%;
      margin-top:4px;
      padding:0px;
      margin-left:4px;
      text-align:center;
}
</style>

</head>

<body onload="window.resizeTo(500,445);" >
<form onsubmit="return verify_form(this)" name="form_invite" action="?status=result" method="post">

<?

function email($email){
if (ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $email)){
return true;
}else{
    return false;
}
}

if(isset($_GET["status"])) { $status = $_GET["status"]; } else { $status = '';}

if($status=='result') {

echo '<div class="all_screen"><p align="left">';

$name_from = $_POST['name_from'];
$email_from = $_POST['email_from'];
$name_to = $_POST['name_to'];
$email_to = $_POST['email_to'];
$msg = nl2br(strip_tags($_POST['msg']));

$n_friends = count($name_to);
$error = 0;

if ( empty($name_from) ) { echo " - Full your name<br />"; $error ++; }
if ( empty($email_from) ) { echo " - Full your email<br />"; $error ++; }
if ( !email($email_from)) { echo " - Full correctly your email<br />"; $error ++; }
if ( ($n_friends == 1) and (empty($email_to[0])) ) { echo " - Full your friends<br />"; $error ++;}
if ( $error != 0 ) { echo ' - <a href="javascript:history.go(-1)">Go back</a>'; } else {

echo 'Thank\'s '.$name_from.' to invite your friends to vistit our website.<BR /><BR />';

$subject = 'Indication';
$from = ''.$name_from.'< '.$email_from.' >';

for($i=0;$i<$n_friends;$i++){ $x = $i + 1;
if ((empty($name_to[$i])) or (empty($email_to[$i]))) { $this_mail = 'Don\'t send'; $this_status = 0; } else { $this_mail = 'Email sended correctly'; $this_status = 1;}
if (!email($email_to[$i])) { $this_mail = 'Don\'t send'; }
echo "$x - $name_to[$i] - $this_mail <br>";

if ($this_status ==  0 ) { } else {
$email = $email_to[$i];
$msg_email = "Hello $name_to[$i], your friend $name_from send you a invite to visit our website and write this: <BR /><BR /> $msg <BR /><BR />www.eletronicparty.com";

@ mail ($email, $subject, $msg_email, "From: $from\nContent-type:text/html;charset=ISO-8859-1;MULTIPART/related");
}
} // close for

} // close else send email
echo '</p></div>';
}  // close if status==result

?>

<div class="all_screen">
<label for="nome" class="row_left">Your name:</label>
<div class="row_right">
<input name="name_from" type="text" value="" size="38" maxlength="100" />
</div>
<div class="clear"> </div>
</div>

<div class="all_screen">
<label for="nome" class="row_left">Your email:</label>
<div class="row_right">
<input name="email_from" type="text" value="" size="38" maxlength="100" />
</div>
<div class="clear"> </div>
</div>

<div class="all_screen">
Write in this box a message to your friend(s).<br />
<textarea name="msg" style="width: 340px; height:100px;"></textarea>
</div>

<div class="all_screen">
Put down your friends ! Click in plus to add more a friend .
</div>

<div class="all_screen">
<table><tr><td>
Name <input type="text" size="15" name="name_to[]">
Email <input type="text" size="15" name="email_to[]">
<input type="button" name="drop" value="-" onClick="dropFile(this);" >
<input type="button" name="add"  value="+" onClick="addFile(this);">
</td></tr></table>
</div>

<div class="all_screen">
<input type="submit" value="Send" name="Send" /></p><BR /><BR />
</div>

</form>
</body>
</html> 

Scripts recomendados

Variação de chec classe

Multiplos em PHP

Enviando SMS

SysMail v.0.1 BETA

Livro Visitas


  

Comentários
[1] Comentário enviado por acombat em 30/07/2008 - 23:14h

OI Felipe,

Como faço para validar e ter um banco de dados deste script, pois quando aperto f12 no DW ele mostra a página mas dá este erro acima

*********************************************
$subject = 'Indication';
$from = ''.$name_from.'< '.$email_from.' >';

for($i=0;$i<$n_friends;$i++){ $x = $i + 1;
if ((empty($name_to[$i])) or (empty($email_to[$i]))) { $this_mail = 'Don\'t send'; $this_status = 0; } else { $this_mail = 'Email sended correctly'; $this_status = 1;}
if (!email($email_to[$i])) { $this_mail = 'Don\'t send'; }
echo "$x - $name_to[$i] - $this_mail <br>";

if ($this_status == 0 ) { } else {
$email = $email_to[$i];
$msg_email = "Hello $name_to[$i], your friend $name_from send you a invite to visit our website and write this: <BR /><BR /> $msg <BR /><BR />www.eletronicparty.com";

@ mail ($email, $subject, $msg_email, "From: $from\nContent-type:text/html;charset=ISO-8859-1;MULTIPART/related");
}
} // close for

} // close else send email
echo '</p></div>';
} // close if status==result

?>
******************************************

Como posso fazer para q ele funcione? Não tenho muita experiência em programação.

Aguardo seu retorno e obrigada.



Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts