Jump to content

email verification issues......


Jayden_Blade

Recommended Posts

<?php
error_reporting(E_ALL);

if ($_POST) {
	$year2 = date('Y');
	$year = (date('Y') - 18);
	$month = date('m');
	$day = date('d');
	$datecheck = mktime(0,0,0,$month,$day,$year);
	$yearcheck = mktime(0,0,0,$_POST['month'],$_POST['day'],$_POST['year']);
	#$birthday = ($_POST['month'],$_POST['day'],$_POST['year']);
	#echo "Month: $month, Year: $year, Day: $day, Check: $datecheck";
	#echo $yearcheck;
	if( $datecheck >= $yearcheck){
	echo"date check";
	}
	else {
		header ('location: http://www.google.com');
	}	
#$birthday= ($_POST['month'],$_POST['day'],$_POST['year']);



	$check = array('user','password1','password2','email1','email2','age','location','agree'); 
	$break = false;
	foreach ($check as $key => $postcheck) { 
		if (!$_POST[$postcheck] || strlen($_POST[$postcheck]) == 0) { 
			$break = true;
			echo "spot = $postcheck<br />";
			break;
		} 
	}
	if ($break) {
		echo "Fields are blank";
		exit;
	} else {
		//echo "<pre>";print_r($_POST);echo "</pre>";
	}

	if( strlen( $_POST['user'] ) < 4 ) {
		$ERROR = TRUE;
		echo "Username Must Be More Than 4 Characters.";

	}
	if( strlen( $_POST['password1'] ) < 4 ) {
		$ERROR = TRUE;
		echo "Password Must Be More Than 4 Characters.";

	}
	if( $_POST['password1'] == $_POST['user'] ) {
		$ERROR = TRUE;
		echo"Username And Password Can Not Be The Same.";

	}
	if( $_POST['password1'] !== $_POST['password2'] ) {
		$ERROR = TRUE;
		echo"Passwords are not the same. Try again.";

	}
	if( $_POST['email1'] !== $_POST['email2'] ) {
		$ERROR = TRUE;
		echo"Emails are not the same. Try again.";

	}
	if( $_POST['agree'] != 'on') {
		$ERROR = TRUE;
		echo "You Must agree you are 18+ and agree to TOS to register.";
	}
	if( strlen( $_POST['human'] ) > 0 ) {
		$ERROR = TRUE;
		echo "Please Remove the text from the Human Checker Box to continue!";
	}
	if ($ERROR) {
	} else {
		echo"database look up"
		include( 'database.php' );
		echo"starting email";
		$username = mysql_real_escape_string( $_POST['user'] );
		$password1 = md5( $_POST['password1'] );
		
		$email1 = mysql_real_escape_string($_POST['email1']);
	    		
	    		
		if (!filter_var(trim($_POST['email']),, $email1)){
		echo 'Email is incorrect';
			// Return Error - Invalid Email
			$msg = 'The email you have entered is invalid, please try again.';
			}else{
			// Return Success - Valid Email
			$msg = 'Your account has been made, <br /> please verify it by clicking the activation link that has been send to your email.';
			$hash = md5( rand(0,1000) ); // Generate random 32 character hash and assign it to a local variable.
			// Example output: f4552671f8909587cf485ea990207f3b 
			}
		
		

		$sqlCheckForDuplicate = "SELECT username FROM user WHERE username = '$_POST[user]'";
		if( mysql_num_rows( mysql_query( $sqlCheckForDuplicate ) ) == 0 ) {
			$sqlRegUser = 	"INSERT INTO
						user( username, password, email, agree, hash )
					VALUES(
						'$_POST[user]',
						'$_POST[$password1]',
						'$_POST[email1]',
						'$_POST[agree]',
						'$_POST[$hash]'
						)";
			error_reporting(E_ALL);
			$to      = $email1; // Send email to our user
			$subject = 'Signup | Verification'; // Give the email a subject 
			$message = '

			Thanks for signing up!
			Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.

			------------------------
			Username: '.$name.'
			Password: '.$password1.'
			------------------------

			Please click this link to activate your account:

			http://www.yourwebsite.com/verify.php?email='.$email1.'&hash='.$hash.'

			'; // Our message above including the link
								
			$headers = 'From:noreply@yourwebsite.com<script type="text/javascript">
			/* <![CDATA[ */
			(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
			/* ]]> */
			</script>' . "\r\n"; // Set from headers
			mail($to, $subject, $message, $headers); // Send our email

			
			mysql_query($sqlRegUser) or die("user insert = <br />".mysql_error());
			$sqlRegUsera = 	"INSERT INTO
						profiledata( username, age, sex, sexpref, maritalstatus, location, lookingfor, children, smoking, drinking, lastlog, sign_up_date )
					VALUES(
						'$_POST[user]',
						'$_POST[age]',
						'$_POST[sex]',
						'$_POST[sexpref]',
						'$_POST[maritalstatus]',
						'$_POST[location]',
						'$_POST[lookingfor]',
						'$_POST[children]',
						'$_POST[smoking]',
						'$_POST[drinking]',
						'$_POST[lastlog]',
						now()
						)";
			mysql_query($sqlRegUsera) or die("profiledata insert = <br />".mysql_error());
			$sqlRegUsera = 	"INSERT INTO
						aboutme( username, aboutme)
					VALUES(
						'$_POST[user]',
						'$_POST[aboutme]'
						)";
			mysql_query($sqlRegUsera) or die("aboutme insert = <br />".mysql_error());
			$sqlRegUsera = 	"INSERT INTO
						interests( username, interests )
					VALUES(
						'$_POST[user]',
						'$_POST[interests]'
						)";
			mysql_query($sqlRegUsera) or die("interests insert = <br />".mysql_error());
			$sqlRegUserb = 	"INSERT INTO
						fetishes( username, fetishes )
					VALUES(
						'$_POST[user]',
						'$_POST[fetishes]'
						)";
			mysql_query($sqlRegUserb) or die("fetishes insert = <br />".mysql_error());
			$sqlRegUserc = "INSERT INTO
						navigation( username )
					VALUES
						'$_POST[user]'
						)";
			$id = mysql_insert_id();
			//echo $id;
			mkdir("members/$id", 0755);

		}
		else
		{
			echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another One.";
			$formUsername = $username;
		}
	}
}
else
{
	echo "You Could Not Be Registered Because Of Missing Data.";
}	
?> 

First off I am still considered a noob when it comes to programming.... I am trying to create an email verification script inside my registration. What is wrong??? Please help!

When I try to register it just sits at a blank page. It does NOT add anything to the tables. If I take ALL of the email verification scripts out it works again.

Link to comment
Share on other sites

Perhaps your server is set to hide errors. In addition to enabling error, try adding a line to display them:

error_reporting(E_ALL);
ini_set('display_errors', 1);
 
If you still don't see any errors, you could try removing all the code which prevents the page from running. Then slowly add everything back (one block at a time) until the page breaks. That should help you figure out which block of code is causing the error.
Link to comment
Share on other sites

FYI, Dreamweaver also indicates that you have an extra comma in the if statement here:

if (!filter_var(trim($_POST['email']),, $email1)){
echo 'Email is incorrect';
 
It also doesn't like this line:
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute(\'data-cfemail\');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
 
Perhaps that will narrow things down.
Link to comment
Share on other sites

For that JavaScript line, it looks like you need to escape all the single quotes. Try

 

(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute(\'data-cfemail\');if(a){s=\'\';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
Link to comment
Share on other sites

First.... THANKS ALOT! 

 

Second..... Now it is giving me errors lol

 

 

here is the errors now

 

 

date checkdatabase look upstarting email Warning: filter_var() expects parameter 2 to be long, string given in C:\Users\Jayden\Desktop\UniServerZ\www\regcheck.php on line 86 Email is incorrect Notice: Undefined index: fe383b22953805123e0c5461264bd33a in C:\Users\Jayden\Desktop\UniServerZ\www\regcheck.php on line 105 Notice: Undefined variable: hash in C:\Users\Jayden\Desktop\UniServerZ\www\regcheck.php on line 108 Notice: Undefined index: in C:\Users\Jayden\Desktop\UniServerZ\www\regcheck.php on line 108 Notice: Undefined variable: hash in C:\Users\Jayden\Desktop\UniServerZ\www\regcheck.php on line 125

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
if ($_POST) {
	$year2 = date('Y');
	$year = (date('Y') - 18);
	$month = date('m');
	$day = date('d');
	$datecheck = mktime(0,0,0,$month,$day,$year);
	$yearcheck = mktime(0,0,0,$_POST['month'],$_POST['day'],$_POST['year']);
	#$birthday = ($_POST['month'],$_POST['day'],$_POST['year']);
	#echo "Month: $month, Year: $year, Day: $day, Check: $datecheck";
	#echo $yearcheck;
	if( $datecheck >= $yearcheck){
	echo"date check";
	}
	else {
		header ('location: http://www.google.com');
	}	
#$birthday= ($_POST['month'],$_POST['day'],$_POST['year']);



	$check = array('user','password1','password2','email1','email2','age','location','agree'); 
	$break = false;
	foreach ($check as $key => $postcheck) { 
		if (!$_POST[$postcheck] || strlen($_POST[$postcheck]) == 0) { 
			$break = true;
			echo "spot = $postcheck<br />";
			break;
		} 
	}
	if ($break) {
		echo "Fields are blank";
		exit;
	} else {
		//echo "<pre>";print_r($_POST);echo "</pre>";
	}

	if( strlen( $_POST['user'] ) < 4 ) {
		$ERROR = TRUE;
		echo "Username Must Be More Than 4 Characters.";

	}
	if( strlen( $_POST['password1'] ) < 4 ) {
		$ERROR = TRUE;
		echo "Password Must Be More Than 4 Characters.";

	}
	if( $_POST['password1'] == $_POST['user'] ) {
		$ERROR = TRUE;
		echo"Username And Password Can Not Be The Same.";

	}
	if( $_POST['password1'] !== $_POST['password2'] ) {
		$ERROR = TRUE;
		echo"Passwords are not the same. Try again.";

	}
	if( $_POST['email1'] !== $_POST['email2'] ) {
		$ERROR = TRUE;
		echo"Emails are not the same. Try again.";

	}
	if( $_POST['agree'] != 'on') {
		$ERROR = TRUE;
		echo "You Must agree you are 18+ and agree to TOS to register.";
	}
	if( strlen( $_POST['human'] ) > 0 ) {
		$ERROR = TRUE;
		echo "Please Remove the text from the Human Checker Box to continue!";
	}
	//if ($ERROR = TRUE) {
	//echo "Please try again!";
	//}
	else {
		echo"database look up";
		include( 'database.php' );
		echo"starting email";
		$username = mysql_real_escape_string( $_POST['user'] );
		$password1 = md5( $_POST['password1'] );
		
		$email1 = mysql_real_escape_string($_POST['email1']);
	    		
	    		
		if (!filter_var(trim($_POST['email1']), $email1)){
			echo 'Email is incorrect';
			// Return Error - Invalid Email
			$msg = 'The email you have entered is invalid, please try again.';
			}else{
			// Return Success - Valid Email
			$msg = 'Your account has been made, <br /> please verify it by clicking the activation link that has been send to your email.';
			$hash = md5( rand(0,1000) ); // Generate random 32 character hash and assign it to a local variable.
			// Example output: f4552671f8909587cf485ea990207f3b 
			}
		
		

		$sqlCheckForDuplicate = "SELECT username FROM user WHERE username = '$_POST[user]'";
		if( mysql_num_rows( mysql_query( $sqlCheckForDuplicate ) ) == 0 ) {
			$sqlRegUser = 	"INSERT INTO
						user( username, password, email, agree, hash )
					VALUES(
						'$_POST[user]',
						'$_POST[$password1]',
						'$_POST[email1]',
						'$_POST[agree]',
						'$_POST[$hash]'
						)";
			error_reporting(E_ALL);
			$to      = $email1; // Send email to our user
			$subject = 'Signup | Verification'; // Give the email a subject 
			$message = '

			Thanks for signing up!
			Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.

			------------------------
			Username: '.$username.'
			Password: '.$password1.'
			------------------------

			Please click this link to activate your account:

			http://www.yourwebsite.com/verify.php?email='.$email1.'&hash='.$hash.'

			'; // Our message above including the link
								
			$headers = 'From:noreply@yourwebsite.com<script type="text/javascript">
			/* <![CDATA[ */
			(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute(\'data-cfemail\');if(a){s=\'\';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
			/* ]]> */
			</script>' . "\r\n"; // Set from headers
			mail($to, $subject, $message, $headers); // Send our email

			
			mysql_query($sqlRegUser) or die("user insert = <br />".mysql_error());
			$sqlRegUsera = 	"INSERT INTO
						profiledata( username, age, sex, sexpref, maritalstatus, location, lookingfor, children, smoking, drinking, lastlog, sign_up_date )
					VALUES(
						'$_POST[user]',
						'$_POST[age]',
						'$_POST[sex]',
						'$_POST[sexpref]',
						'$_POST[maritalstatus]',
						'$_POST[location]',
						'$_POST[lookingfor]',
						'$_POST[children]',
						'$_POST[smoking]',
						'$_POST[drinking]',
						now(),
						now()
						)";
			mysql_query($sqlRegUsera) or die("profiledata insert = <br />".mysql_error());
			$sqlRegUsera = 	"INSERT INTO
						aboutme( username, aboutme)
					VALUES(
						'$_POST[user]',
						'$_POST[aboutme]'
						)";
			mysql_query($sqlRegUsera) or die("aboutme insert = <br />".mysql_error());
			$sqlRegUsera = 	"INSERT INTO
						interests( username, interests )
					VALUES(
						'$_POST[user]',
						'$_POST[interests]'
						)";
			mysql_query($sqlRegUsera) or die("interests insert = <br />".mysql_error());
			$sqlRegUserb = 	"INSERT INTO
						fetishes( username, fetishes )
					VALUES(
						'$_POST[user]',
						'$_POST[fetishes]'
						)";
			mysql_query($sqlRegUserb) or die("fetishes insert = <br />".mysql_error());
			$sqlRegUserc = "INSERT INTO
						navigation( username )
					VALUES
						'$_POST[user]'
						)";
			$id = mysql_insert_id();
			//echo $id;
			mkdir("members/$id", 0755);

		}
		else
		{
			echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another One.";
			$formUsername = $username;
		}
	}
}
else
{
	echo "You Could Not Be Registered Because Of Missing Data.";
}	
?>
Link to comment
Share on other sites

It doesn't like this code.... Am I missing something? Or would it be better doing it a different way? The original code used eregi which is outdated now.

 

 


		if (!filter_var(trim($_POST['email1']), $email1)){
			echo 'Email is incorrect';
			// Return Error - Invalid Email
			$msg = 'The email you have entered is invalid, please try again.';
			}else{
			// Return Success - Valid Email
			$msg = 'Your account has been made, <br /> please verify it by clicking the activation link that has been send to your email.';
			$hash = md5( rand(0,1000) ); // Generate random 32 character hash and assign it to a local variable.
			// Example output: f4552671f8909587cf485ea990207f3b 
			}

Thanks again for the help!

Link to comment
Share on other sites

SMTP error from remote mail server after end of data:
host k2smtpout-v01.prod.mesa1.secureserver.net [64.202.189.86]:
552 5.2.0 tJhP1m00K2k7bSo01 :: DEDCPANEL:: Message rejected for spam or virus content ::
Please include this entire message when contacting support ::
v=2.0 cv=B75nJpRM c=1 sm=1 p=Zycs2LkzuxUA:10 a=/YMFs7hsgfZFS9+pD+TI1Q==:17 a=0rp-iRRafjwA:10 a=GYKhdZzdMAoA:10 a=UfYdpAudXA0A:10 a=Fhs_hUukvqMA:10 a=TZb1taSUAAAA:8 a=6kIOgtkx3iQA:10 a=dbRHsw5eAAAA:8 a=CjxXgO3LAAAA:8 a=oHJmyixqeM73gJEqkaAA:9 a=iKupZL6ZdNsA:10 a=djbTbbvMrfMA:10 a=rC2wZJ5BpNYA:10 a=2J9aSTsWCMoA:10 a=La303XB5pKgA:10 a=/YMFs7hsgfZFS9+pD+TI1Q==:117 ::
100.00

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.