Jump to content


Photo

Ajuda Com Resgitro + Newsletter


  • Faça o login para participar
1 reply to this topic

#1 Rodrigo Ap.

Rodrigo Ap.

    Novato no fórum

  • Usuários
  • 13 posts
  • Sexo:Masculino

Posted 23/01/2011, 17:07

Olá Galera to precisando da ajuda de vcs...

Minha pagina de registro na esta incluindo o Email do usuario na coluna de newsletter (newsletter_email), tipo o usuario faz o registro seleciona o campo receber noticias, so que o email que ele esta colocando para o registro na esta sendo acrescentado na coluna (newsletter_email).

Alguém saberia como configurar o script abaixo para copiar o email de cadastro para a coluna (newsletter_email)

OBRIGADO


<?
	include("config/connect.php");
	include("sendmail.php");
	include("functions.php");

	if($_GET["ref"]!="")
	{
		$_SESSION["refid"] = $_GET["ref"];
	}

	if($_POST["username"]!="")
	{
		$username = $_POST["username"];
		$gender = $_POST["gender"];
		$fname = $_POST["firstname"];
		$lname = $_POST["lastname"];
		$bdate = setdate($_POST["month"],$_POST["date"],$_POST["year"]);
//		$bdate = $_POST["month"]."-".$_POST["date"]."-".$_POST["year"];
		$pass = $_POST["password"];
		$email = $_POST["email"];
		$mobile = $_POST["mobileno"];
		$terms = $_POST["terms"];
		$privacy = $_POST["privacy"];		
		$news = $_POST["newslatter"];
		$rndcode = strtolower($_POST["rndcode"]);
		$countryinfo = explode("|",$_POST["countrycode"]);
		$countrycode = $countryinfo[0];
		$countryID = $countryinfo[1];
		$fullmobile = "+".$countrycode.$mobile;
		
		$addressline1 = $_POST["addressline1"];
		$addressline2 = $_POST["addressline2"];
		$city = $_POST["city"];
		$state = $_POST["state"];
		$phoneno = $_POST["phoneno"];
		$postcode = $_POST["postcode"];
		
// user duplication check

		$qrysel = "select * from registration where username='$username' or email='$email' or phone='$phoneno'";
		$ressel = mysql_query($qrysel);
		$totalrows = mysql_affected_rows();
		$obj = mysql_fetch_object($ressel);
		if($totalrows>0)
		{
			if($email==$obj->email)
			{
			$err=1;
			}
			else if ($phoneno==$obj->phone)
			{
			$err=4;
			}
			else
			{
			$err=2;
			}
		}
		elseif($_SESSION['security_code']!=$rndcode)
		{
			$err3=3;
		}
// end duplication check
		else
		{
			$verifycode = md5($username);
		$qryins = "Insert into registration (username, firstname, lastname, sex,birth_date, email, password, terms_condition, privacy, newslatter,final_bids,sponser,mobile_no,register_date,country,full_mobileno,addressline1,addressline2,city,state,phone,verify_code,postcode) values('$username','$fname','$lname','$gender','$bdate','$email','$pass','$terms','$privacy','$news','5','".$_SESSION["refid"]."','$mobile',NOW(),'$countryID','$fullmobile','$addressline1','$addressline2','$city','$state','$phoneno','$verifycode','$postcode')";
		mysql_query($qryins) or die(mysql_error());
		$_SESSION["uid"] = mysql_insert_id();

		$uid = $_SESSION["uid"];
		
		$auction_username = $username;
		$auction_userid = $_SESSION["uid"];
//		$encode_userid = base64_encode($_SESSION["uid"]);
//		$encode_username = base64_encode($username);
//		$encode_password = base64_encode($pass);
		
		$emailcont1 = sprintf($lng_emailcontent_registraion,$fname,$auction_username,$auction_userid,$verifycode);
		
		$subject=$lng_mailsubjectaccinfo;
		$from=$adminemailadd;
		
		SendHTMLMail($email,$subject,$emailcont1,$from);
//		header("location: registration.php");
		}
	}	
?>
<!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=<?=$lng_characset;?>" />
<title><?=$AllPageTitle;?></title>
<link href="css/style_youbid.css" rel="stylesheet" type="text/css" />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<link href="css/estilo.css" rel="stylesheet" type="text/css" />
<!--[if IE 8]>
<link href="css/estiloie8.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE 7]>
<link href="css/estiloie7.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if lte IE 6]>
<link href="css/menu_ie.css" rel="stylesheet" type="text/css" />
<![endif]-->
<script language="javascript" src="pwd_strength.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="function.js"></script>
<script language="javascript">
function Check()
{
	if(document.registration.firstname.value=="")
	{
		alert("<?=$lng_regenterfirstname;?>");
		document.registration.firstname.focus();
		return false;
	}
	
	if(document.registration.lastname.value=="")
	{
		alert("<?=$lng_regenterlastname;?>");
		document.registration.lastname.focus();
		return false;
	}
	
	if(document.registration.date.value=="dd")
	{
		alert("<?=$lng_regselbirthdate;?>");
		document.registration.date.focus();
		return false;
	}
	
	if(document.registration.month.value=="mm")
	{
		alert("<?=$lng_regselbirthdate;?>");
		document.registration.month.focus();
		return false;
	}
	
	if(document.registration.year.value=="yyyy")
	{
		alert("<?=$lng_regselbirthdate;?>");
		document.registration.year.focus();
		return false;
	}
	
	if(document.registration.addressline1.value=="")
	{
		alert("<?=$lng_regenteraddress;?>");
		document.registration.addressline1.focus();
		return false;
	}
	
	if(document.registration.city.value=="")
	{
		alert("<?=$lng_regentercity;?>");
		document.registration.city.focus();
		return false;
	}

/*	if(document.registration.state.value=="")
	{
		alert("Please Enter State!");
		document.registration.state.focus();
		return false;
	}*/

	if(document.registration.postcode.value=="")
	{
		alert("<?=$lng_regenterpostcode;?>");
		document.registration.postcode.focus();
		return false;
	}

	if(document.registration.username.value.length < 6)
	{
		alert("<?=$lng_regusernametooshort;?>");
		document.registration.username.focus();
		document.registration.username.select();
		return false;
	}
	
	if(document.registration.password.value=="")
	{
		alert("<?=$lng_regenterpassword;?>");
		document.registration.password.focus();
		return false;
	}
	
	if(document.registration.password.value.length<6)
	{
		alert("<?=$lng_regpasstooshort;?>");
		document.registration.password.focus();
		return false;
	}
	
	if(document.registration.cnfpassword.value=="")
	{
		alert("<?=$lng_regconfpassword;?>");
		document.registration.cnfpassword.focus();
		return false;
	}
	
	if(document.registration.password.value!=document.registration.cnfpassword.value)
	{
		alert("<?=$lng_regpassmismatch;?>");
		document.registration.cnfpassword.focus();
		return false;
	}
	
	if(document.registration.email.value=="")
	{
		alert("<?=$lng_regenteremailadd;?>");
		document.registration.email.focus();
		return false;
	}
	else
	{
		if(!validate_email(document.registration.email.value,"<?=$lng_entervalidemail;?>"))
			{
				document.registration.email.select();
				return false;
			}
	}
	if(document.registration.cnfemail.value=="")
	{
		alert("<?=$lng_regenterconfemail;?>");
		document.registration.cnfemail.focus();
		return false;
	}
	
	if(document.registration.email.value!=document.registration.cnfemail.value)
	{
		alert("<?=$lng_regemailmismatch;?>");
		document.registration.cnfemail.focus();
		return false;
	}
	
	if(document.registration.terms.checked!=true)
	{
		alert("<?=$lng_regreadterms;?>");
		document.registration.terms.focus();
		return false;
	}
	
	if(document.registration.privacy.checked!=true)
	{
		alert("<?=$lng_regreadprivacy;?>");
		document.registration.privacy.focus();
		return false;
	}
	
	if(document.registration.rndcode.value=="")
	{
		alert("<?=$lng_regenterseccode;?>");
		document.registration.rndcode.focus();
		return false;
	}
	document.registration.submit();
}

	function validate_email(field,alerttxt){
		with (field){
			var value;
			value = document.registration.email.value;
			apos=value.indexOf("@");
			dotpos=value.lastIndexOf(".");
			if (apos<1||dotpos-apos<2){
				alert(alerttxt);return false;
			}else{
				return true;
			}
		}
	}
	function validacpf(){
var i;
s = document.registration.phoneno.value;
var c = s.substr(0,9);
var dv = s.substr(9,2);
var d1 = 0;
for (i = 0; i < 9; i++)
{
d1 += c.charAt(i)*(10-i);
}
if (d1 == 0){
alert("CPF Invalido")
document.registration.phoneno.focus();
return false;
}
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(0) != d1)
{
alert("CPF Invalido")
document.registration.phoneno.focus();
return false;
} 
d1 *= 2;
for (i = 0; i < 9; i++)
{
d1 += c.charAt(i)*(11-i)
}
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(1) != d1)
{
alert("CPF Invalido")
document.registration.phoneno.focus();
return false;
}
return true;
}
</script>

</head>

<body>
<div id="main_div">
<?
	include("header.php");
?>
		<div id="conteudo-principal">
<h2 id="registrar-tit"><?=$lng_tabregister;?></h2>
<?
	if($_SESSION["uid"]=="")
	{
?>
<ul id="registrar-vantagens">
<li><p><?=$lng_frregistration;?>
<li><p><?=$lng_vouchermessage;?>
<li><p><?=$lng_amazingproducts;?>
</ul>

		  <p>&nbsp;</p>
		  <p align="left" style="padding-left: 50px;"><font size="+1"><?=$lng_registrationdata;?>:</font></p>
			<?
			if ($err == 4) { ?>
				<p align="left" style="margin-top: 25px; padding-left: 50px;" class="red-text-12-b"><? if ($err == 4) { ?>CPF já existente.<? } ?></p>
               <? }
                else if($err!="")
				{
					$errr = $err;
			?>
				<p align="left" style="margin-top: 25px; padding-left: 50px;" class="red-text-12-b"><? if ($err == 4) { ?>CPF já existente.<? } ?> <?=$errr==1?$lng_emailexists:$lng_usernameexists;?>			</p>
			<?
				}
				if($err3!="")
				{
			?>		
					<p align="left" style="margin-top: 35px; padding-left: 50px;" class="red-text-12-b"><?=$lng_correctcode;?></p>
			<?		
				}
			?>
		  <form id="registration" name="registration" method="post" action="registration.php">				  
<h3 class="info-pessoal"><?=$lng_personalinfo;?></h3>
<p>
<span class="registro-campo-esq">
<label for="firstname"><?=$lng_firstname;?></label>
<input type="text" class="campo1" name="firstname" maxlength="100" value="<?=$fname!=""?$fname:"";?>" />
</span>
<span class="registro-campo-dir">
<label for="lastname"><?=$lng_lastname;?></label>
<input type="text" class="campo1" name="lastname" maxlength="100" value="<?=$lname!=""?$lname:"";?>" />				
</span></p>
<p style="clear:both">
<span class="registro-campo-esq">
<label><?=$lng_birthdate;?></label>
<select size="1" name="date" style="float:left;">
				        <option value="dd">DD</option>
							<?
								for($i=1;$i<=31;$i++)
								{
							?>
							  <option <?=$_POST["date"]==$i?"selected":"";?> value="<?=$i<=9?"0".$i:$i;?>"><?=$i<=9?"0".$i:$i;?></option>
							 <?
								}
							 ?>
		            </select>
					<select size="1" name="month" style="float:left;">
						<option selected="selected" value="mm">MM</option>
						<option <?=$_POST["month"]=="01"?"selected":"";?> value="01">Janeiro</option>
						<option <?=$_POST["month"]=="02"?"selected":"";?> value="02">Fevereiro</option>
						<option <?=$_POST["month"]=="03"?"selected":"";?> value="03">Marco</option>
						<option <?=$_POST["month"]=="04"?"selected":"";?> value="04">Abril</option>
						<option <?=$_POST["month"]=="05"?"selected":"";?> value="05">Maio</option>
						<option <?=$_POST["month"]=="06"?"selected":"";?> value="06">Junho</option>
						<option <?=$_POST["month"]=="07"?"selected":"";?> value="07">Julho</option>
						<option <?=$_POST["month"]=="08"?"selected":"";?> value="08">Agosto</option>
						<option <?=$_POST["month"]=="09"?"selected":"";?> value="09">Setembro</option>
						<option <?=$_POST["month"]=="10"?"selected":"";?> value="10">Outubro</option>
						<option <?=$_POST["month"]=="11"?"selected":"";?> value="11">Novembro</option>
						<option <?=$_POST["month"]=="12"?"selected":"";?> value="12">Dezembro</option>
            </select>
			<select name="year" style="float:left;">
              <option selected="selected" style="width:40px" value="yyyy">YYYY</option>
					<?
						for($i=1950;$i<=2020;$i++)
						{
					?>
					  <option <?=$_POST["year"]==$i?"selected":"";?> value="<?=$i;?>"><?=$i;?></option>
					 <?
						}
					 ?>
		    </select>
</span>
<span class="registro-campo-dir">
<label><?=$lng_gender;?></label>

						<select size="1" name="gender">
							<option selected="selected" value="Male"><?=$lng_male;?></option>
							<option <?=$gender=="Female"?"selected":"";?> value="Female"><?=$lng_female;?></option>
			            </select>
</span></p>
<p style="clear:both"><label for="countryname"><?=$lng_country;?></label>
					  <select name="countrycode">
					  	<?
							$qrycou = "select * from countries order by printable_name";
							$rescou = mysql_query($qrycou);
							$totalcou = mysql_num_rows($rescou);
							for($i=1;$i<=$totalcou;$i++)
							{
								$country = mysql_fetch_object($rescou);
						?>
						<option value="<?=$country->countrycode."|".$country->countryId;?>"><?=$country->printable_name;?></option>
						<?
							}
						?>
					  </select>
</p>
<p style="clear:both"><label><?=$lng_addressline1;?></label>
<input type="text" class="campo2" name="addressline1" maxlength="100" value="<?=$addressline1!=""?$addressline1:"";?>" /></p>
				<p>
<span class="registro-campo-esq">
<label><?=$lng_addressline2;?></label>
<input type="text" class="campo1" name="addressline2" maxlength="100" value="<?=$addressline2!=""?$addressline2:"";?>" /></span>
<span class="registro-campo-dir">
<label><?=$lng_towncity;?></label>
<input type="text" class="campo1" name="city" maxlength="100" value="<?=$city!=""?$city:"";?>" /></span></p>
<p>
<span class="registro-campo-esq">
<label><?=$lng_postcode;?></label>
<input type="text" class="campo1" name="postcode" maxlength="100" value="<?=$postcode!=""?$postcode:"";?>" /></span>
<span class="registro-campo-dir">
<label>
<?=$lng_phoneno;?></label>
<input type="text" class="campo1" name="phoneno" onblur="validacpf()" maxlength="100" value="<?=$phoneno!=""?$phoneno:"";?>" /></span></p>


<h3 class="info-login"><?=$lng_logininfo;?></h3>
<p>
<span class="registro-campo-esq">
<label><?=$lng_username;?></label>
					  <? if($errr==2){ ?>					
						<input name="username" type="text" class="campo1" maxlength="16" />
					  <? } else { ?>
						<input name="username" type="text" class="campo1"  maxlength="16" value="<?=$username!=""?$username:"";?>" />
					  <? } ?>	
<span style="display:block; font-size:11"><?=$lng_characterlong;?></span>
</span>	
<span class="registro-campo-dir">
<label>	<?=$lng_mobilenumber;?></label><input name="mobileno" type="text" class="campo1" maxlength="20" value="<?=$mobile!=""?$mobile:"";?>" />
</span></p>

<p style="clear:both">
<span class="registro-campo-esq">
<label><?=$lng_password;?></label><input name="password" class="campo1" type="password" maxlength="16" value="<?=$pass!=""?$pass:"";?>" onkeyup="pwd_test_password(this.value);" />
<span style="display:block; font-size:11"><?=$lng_characterlong;?></span></span>
<span class="registro-campo-dir">
<label><?=$lng_retypepassword;?></label>
<input name="cnfpassword" type="password" class="campo1" maxlength="16" value="<?=$pass!=""?$pass:"";?>" />
<span style="display:block; font-size:11"><?=$lng_passsecurity;?>:</span>
</span></p>

<p style="clear:both">
<span class="registro-campo-esq">
<label><?=$lng_emailaddress;?></label>
					<? if($errr==1){ ?>		
					  <input name="email" type="text" class="campo1" maxlength="150" />
				    <? } else { ?>
					  <input name="email" type="text" class="campo1" maxlength="150" value="<?=$email!=""?$email:"";?>" />
				    <? } ?>
</span>
<span class="registro-campo-dir">
<label><?=$lng_confirmemail;?></label>
					 <? if($errr==1){ ?>		
					  <input name="cnfemail" type="text" class="campo1" maxlength="150" />
					 <? } else { ?>
					  <input name="cnfemail" type="text" class="campo1" maxlength="150" value="<?=$email!=""?$email:"";?>" />
					 <? } ?>
</span></p>
<div style="clear:both"></div>
				  <div style="height: 25px; margin-top:15px;"><input class="checkbox" type="checkbox" name="terms" value="1" <?=$terms=="1"?"checked":"";?> /><?=$lng_acceptterms;?></div>
				  <div style="height: 25px;"><input class="checkbox" type="checkbox" name="privacy" value="1" <?=$privacy=="1"?"checked":"";?> /><?=$lng_acceptprivacy;?></div>
				  <div style="height: 25px;"><input class="checkbox" type="checkbox" name="newslatter" value="1" <?=$news=="1"?"checked":"";?> /><?=$lng_acceptnewsletter;?></div>
				  <div></div>
		   	  </div>			 
			  <div style="height: 15px;">&nbsp;</div>
			 <div class="register-form" style="padding-left: 55px;">
			 	<span id="registrar-botao">
                <input type="image" src="imagens/registrar.jpg" onmouseover="this.style.margin='-52px 0 0 0'" onmouseout="this.style.margin='0 0 0 0'" name="register"  onclick="return Check();" /></span>
		     </div>			  
		</form>
		</div>
<?
	}
	else
	{
		$qrys = "select email from registration where id='".$_SESSION["uid"]."'";
		$ress = mysql_query($qrys);
		$rows = mysql_fetch_object($ress);
?>
		<div style="height: 25px;">&nbsp;</div>
		<div style="padding-left: 30px; width: 800px; float: left">
			<p align="justify"><?=$lng_confirmregister;?></p> 
			<p align="justify"><?=$lng_sentemailto;?><?=$rows->email;?></p>
			<p align="justify"><?=$lng_registernote;?></p>
			<p align="justify" class="red-text-12-b"><?=$lng_importantword;?></p>
			<p align="justify"><?=$lng_dontreceivenote;?></p>
		<div style="height: 25px;">&nbsp;</div>
		</div>
<?
		unset($_SESSION["uid"]);	
	}
?>
		
<?
	include("footer.php");
?>		
</div>
</body>
</html>

Filmes 24Hrs é um site para que você possa assistir filmes Dublados e Legendados online, com qualidade

www.filmes24hrs.net

Posted Image


#2 Luan Potter

Luan Potter

    Novato no fórum

  • Usuários
  • 5 posts
  • Sexo:Masculino
  • Localidade:Brasil

Posted 15/02/2011, 20:35

Olá! Se entendi bem seu script tem um erro aqui:
$qryins = "Insert into registration (username, firstname, lastname, sex, birth_date, email, password, terms_condition, privacy, newslatter, final_bids, sponser, mobile_no, register_date, country, full_mobileno, addressline1, addressline2, city, state, phone, verify_code, postcode) values('$username', '$fname', '$lname', '$gender','$bdate', '$email', '$pass', '$terms', '$privacy', '$news', '5', '".$_SESSION["refid"]."', '$mobile', NOW(), '$countryID', '$fullmobile', '$addressline1', '$addressline2', '$city', '$state', '$phoneno', '$verifycode', '$postcode')";
Não entendi por que você está jogando algumas informações no bancõ de dados, por exemplo, se terms_condition ($terms) é aquele checkbox que você tem que marcar se aceita os termos, você não devia por ele na tabela, mas dar um if e se for 1 você continua com o cadastro, se for 0 você mostra um erro ou alguma coisa. Privacy também, pelo que vi em:
<input class="checkbox" type="checkbox" name="terms" value="1" <?=$terms=="1"?"checked":"";?> /><?=$lng_acceptterms;?>
<input class="checkbox" type="checkbox" name="privacy" value="1" <?=$privacy=="1"?"checked":"";?> /><?=$lng_acceptprivacy;?>
<input class="checkbox" type="checkbox" name="newslatter" value="1" <?=$news=="1"?"checked":"";?> /><?=$lng_acceptnewsletter;?>
E aí está o problema do newsletter. Você está pondo a var $news (que é 1 se sim e 0 se não) na tabela (o que na verdade pode funcionar, mas não do jeito que você quer). Para que o e-mail em $email vá para a coluna $newsletter_email, você tem que dar um if, por exemplo (você vem escrevendo newslatter no código em vez de newsletter):
if ($news=="1"){
$qryins = "Insert into registration (username, firstname, lastname, sex, birth_date, email, password, terms_condition, privacy, newslatter, final_bids, sponser, mobile_no, register_date, country, full_mobileno, addressline1, addressline2, city, state, phone, verify_code, postcode, newsletter_email) values('$username', '$fname', '$lname', '$gender','$bdate', '$email', '$pass', '$terms', '$privacy', '$news', '5', '".$_SESSION["refid"]."', '$mobile', NOW(), '$countryID', '$fullmobile', '$addressline1', '$addressline2', '$city', '$state', '$phoneno', '$verifycode', '$postcode', '$mail')";
//veja que adicionei o email fornecido e não o valor 1 da var $news
} else {
$qryins = "Insert into registration (username, firstname, lastname, sex, birth_date, email, password, terms_condition, privacy, newslatter, final_bids, sponser, mobile_no, register_date, country, full_mobileno, addressline1, addressline2, city, state, phone, verify_code, postcode) values('$username', '$fname', '$lname', '$gender','$bdate', '$email', '$pass', '$terms', '$privacy', '$news', '5', '".$_SESSION["refid"]."', '$mobile', NOW(), '$countryID', '$fullmobile', '$addressline1', '$addressline2', '$city', '$state', '$phoneno', '$verifycode', '$postcode')";
Obs. Não tirei aqueles campos que comenetei, se quiser pode fazer isso.
Obs2. Como disse, você pode usar do jeito que está, mas em vez de enviar newsletters para todos os e-mails na coluna newsletter_email como sugeriu, você podia primeiro checar se o valor da coluna newsletter era 1 e depois enviá-lo para o e-mail em email somente nesse caso.

Edição feita por: Luan Potter, 15/02/2011, 20:39.





1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq