Jump to content

Index.php long php script, was barely functioing now, not at all


HoTDaWg

Recommended Posts

one problem is that im getting the following error:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_CASE or T_DEFAULT or '}' in /home/xdesigns/public_html/index.php on line 18

now,  before it would give me some error along the lines of:

Warning: undefined index mode.

even then, it would insert the stuff into the db but give an error message that an unexpected error occurred. it wouldnt even send the email.

here is my script:

<?php
error_reporting(E_ALL);
$ip = $_SERVER['REMOTE_ADDR'];
$date = date('l, F j, Y @ g:i:s A e');
$sitename = "Yadayada";
$slogan = "Slogan here";
$subscribetext= "Join...NOW!";
$emailform = '<form method="POST" name="addsubscriber" action="http://www.mysite.com/index.php?mode=emailsubmit"><br>'.$subscribetext.'<br>Email:<input name="emailaddress" maxlength="80" value=""><br><input type="submit" value="Submit!"></form>';
$conn = mysql_connect("localhost","*********","*******");
mysql_select_db("************");
$adminemail = '***********';

if (!isset($_GET['mode'])) {
$mode = "home";
}

switch($mode){
$contentecho = array();
$email = $_POST["emailaddress"];
case 'emailsubmit':
$emailerror = array();
	if(strlen($email) < 1){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email field was was not complete</font></li>';
	}
	if(strlen($email) > 80){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email field exeeds the limit of 80 characters</font></li>';
	}
	if(preg_match('|[^-_.@a-z\d]|i', $email)){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email Field contains invalid characters. Alphanumeric, @,-,and _ characters are the only characters accepted due to security reasons.</font></li>';
	}
	$emailexists = "SELECT email FROM subscribers WHERE email='$email'";
	$selectemailexists = mysql_query($emailexists,$conn);
		if(mysql_num_rows($selectemailexists) > 0){
		$emailerror['email'] .='<li><font color="#FF0000">This Email is already registered as a subscriber.</font></li>';
		}
	if(count($emailerror) < 1){
	$usercode = rand(0,1000000);
	$status = 'blank';
	$insertemail = "INSERT INTO subscribers(`id`,`email`,`usercode`,`date`,`ip`,`status`) VALUES('','$email','$usercode','$date','$ip','$status')";
	$insertemailnow = mysql_query($insertemail,$conn);
		if($insertemailnow){
		$message="Thanks for registering on our website! Open a new window and go to http://www.*********.com/index.php?email=$email&mode=verify&usercode=$usercode to complete your registration. Thanks.";
      		$to = &$email;
      		$subject = 'Validate This Email';
      		$headers = 'From: ****@******.com' . "\r\n" .
      		'Reply-To: ****@******.com' . "\r\n" .
//This statement helps out with spam filters
      		'X-Mailer: PHP/' . phpversion();
//Send the email
      		$mailnow = mail($to, $subject, $message, $headers,"****@******.com");
			if($mailnow){
			$contentecho ='Thank you for registering. A verification email has been dispatched to your email address. Please check your spam/junk mail folders if the email does not appear in your inbox. If the email does not appear at all within 24 hours contact the administrator. Thanks again.';
			}else{
			$contentecho ='An error occurred with your submission. Please try again.';
			}
		}else{
		$contentecho ='An error occurred with your submission. Please try again.';
		}
	}else{
		foreach ($emailerror as $error){
		$echoemailerrors .= ''.$error.'';
		} 
	$content = array();
	$content['text'] .= 'The following errors were found in your submission:<br>'.$echoemailerrors.'<br>';
	$content['text'] .= ''.$emailform.'';
		foreach ($content as $text){
		$contentecho .= ''.$text.'';
		}
	}
break;
//BEGIN VERIFY
case 'verify':
$usercode = $_GET['usercode'];
$email = $_GET['email'];
$validateerror = array();
	if(empty($usercode) || empty($email)){
	$validateerror['empty'] .= '<li><font color="#FF0000">This page was accessed incorrectly.</font></li>';
	}
$validatetrue = "SELECT email,usercode FROM subscribtions WHERE email='$email' usercode='$usercode' status='good'";
$validatetruenow = mysql_query($validatetrue,$conn);
	if(mysql_num_rows($validatetruenow) > 0){
	$validateerror['already_exists'] .= '<li><font color="#FF0000">This email is already subscribed and validated.</font></li>';
	}
	if(count($validateerror) > 0){
	$status = "good";
	$updateemail = "UPDATE subscribers SET status='$status' WHERE usercode='$usercode'";
	$updatemailnow = mysql_query($insertemail,$conn);
		if($updateemailnow){
		$action = "New Email added to subscribers list";
		$insertaction = "INSERT INTO actions(`id`,`action`,`date`,`ip`) VALUES('','$action','$date','$ip')";
		$actionsubmit = mysql_query($insertaction,$conn);
				if($actionsubmit){
				$contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.';
				}else{
				$contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.';
				}
		}else{
		$contentecho .='<li><font color="#FF0000">An error occurred with your verification. Please try again.</font></li>';
		}
	}else{
		foreach($validateerror as $errorkind){
		$contentecho .= ''.$errorkind.'';
		}
	}
break;
        case 'home':
$contentecho =''.$emailform.'';
        break;        
default:
$contentecho =''.$emailform.'';
break;
}
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Welcome!</title>

</head>
<body bgcolor="#999999" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<table width="750" height="0" cellpadding="0" cellspacing="0" border="0" style="Border: 1px solid #000000;">
<tr>
<td bgcolor="#666666" valign="top"><font color="#FFFFFF" face="arial"><b>Under construction</font></b></td>
</tr>
<tr>
<td bgcolor="#cccccc" valign="top">
<table width="98%" border="0">
        <font face="arial" size="3">
        Our website is under construction, bare with us as we create it.<b>Thanks for your consideration.</b><br>
<b>Check back soon!</b><br><br>
<i>The <?php echo $sitename; ?> Team</i></font>
</table>
</td>
</tr>
<tr>
<td bgcolor="#0099FF" valign="top"><font color="#FFFFFF" size="3" face="arial"><B>Sign up for email updates today!</B></font></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" valign="top">
<center>
<table width="98%" border="0">
<?php 	
echo $contentecho;
 ?>
</table>
</center>
</td>
</tr>
</table>
</center>
<h4 align="center">Our website is graciously hosted by <a href="http://guildwutang.com/">X ER Game Hosting</a></h4>
</body>
</html>

thanks for any help possible.

 

HoTDaWg

Link to comment
Share on other sites

thank you both for your help, however, more errors :(

 

once the submit button is pressed the following errors come up:

Notice: Undefined variable: mode in /home/xdesigns/public_html/index.php on line 19

Notice: Undefined variable: mode in /home/xdesigns/public_html/index.php on line 72

Notice: Undefined variable: mode in /home/xdesigns/public_html/index.php on line 106

 

i have changed the code too:

<?php
error_reporting(E_ALL);
$ip = $_SERVER['REMOTE_ADDR'];
$date = date('l, F j, Y @ g:i:s A e');
$sitename = "hahahaa";
$slogan = "hahahaa";
$subscribetext= "Join...NOW!";
$emailform = '<form method="POST" name="addsubscriber" action="http://www.hahahaa.com/index.php?mode=emailsubmit"><br>'.$subscribetext.'<br>Email:<input name="emailaddress" maxlength="80" value=""><br><input type="submit" value="Submit!"></form>';
$conn = mysql_connect("localhost","hahahaa","hahahaa");
mysql_select_db("hahahaa");
$adminemail = 'hahahaa';

if (!isset($_GET['mode'])) {
$mode = "home";
}

$contentecho = array();
switch($mode){
case 'emailsubmit':
$emailerror = array();
	if(strlen($email) < 1){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email field was was not complete</font></li>';
	}
	if(strlen($email) > 80){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email field exeeds the limit of 80 characters</font></li>';
	}
	if(preg_match('|[^-_.@a-z\d]|i', $email)){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email Field contains invalid characters. Alphanumeric, @,-,and _ characters are the only characters accepted due to security reasons.</font></li>';
	}
	$emailexists = "SELECT email FROM subscribers WHERE email='$email'";
	$selectemailexists = mysql_query($emailexists,$conn);
		if(mysql_num_rows($selectemailexists) > 0){
		$emailerror['email'] .='<li><font color="#FF0000">This Email is already registered as a subscriber.</font></li>';
		}
	if(count($emailerror) < 1){
                $email = $_POST["emailaddress"];
	$usercode = rand(0,1000000);
	$status = 'blank';
	$insertemail = "INSERT INTO subscribers(`id`,`email`,`usercode`,`date`,`ip`,`status`) VALUES('','$email','$usercode','$date','$ip','$status')";
	$insertemailnow = mysql_query($insertemail,$conn);
		if($insertemailnow){
		$message="Thanks for registering on our website! Open a new window and go to http://www.hahahaa.com/index.php?email=$email&mode=verify&usercode=$usercode to complete your registration. Thanks.";
      		$to = &$email;
      		$subject = 'Validate This Email';
      		$headers = 'From: hahahaa' . "\r\n" .
      		'Reply-To: hahahaa' . "\r\n" .
//This statement helps out with spam filters
      		'X-Mailer: PHP/' . phpversion();
//Send the email
      		$mailnow = mail($to, $subject, $message, $headers,"bakhtawarawan@gmail.com");
			if($mailnow){
			$contentecho ='Thank you for registering. A verification email has been dispatched to your email address. Please check your spam/junk mail folders if the email does not appear in your inbox. If the email does not appear at all within 24 hours contact the administrator. Thanks again.';
			}else{
			$contentecho ='An error occurred with your submission. Please try again.';
			}
		}else{
		$contentecho ='An error occurred with your submission. Please try again.';
		}
	}else{
		foreach ($emailerror as $error){
		$echoemailerrors .= ''.$error.'';
		} 
	$content = array();
	$content['text'] .= 'The following errors were found in your submission:<br>'.$echoemailerrors.'<br>';
	$content['text'] .= ''.$emailform.'';
		foreach ($content as $text){
		$contentecho .= ''.$text.'';
		}
	}
break;
//BEGIN VERIFY
case 'verify':
$usercode = $_GET['usercode'];
$email = $_GET['email'];
$validateerror = array();
	if(empty($usercode) || empty($email)){
	$validateerror['empty'] .= '<li><font color="#FF0000">This page was accessed incorrectly.</font></li>';
	}
$validatetrue = "SELECT email,usercode FROM subscribtions WHERE email='$email' usercode='$usercode' status='good'";
$validatetruenow = mysql_query($validatetrue,$conn);
	if(mysql_num_rows($validatetruenow) > 0){
	$validateerror['already_exists'] .= '<li><font color="#FF0000">This email is already subscribed and validated.</font></li>';
	}
	if(count($validateerror) > 0){
	$status = "good";
	$updateemail = "UPDATE subscribers SET status='$status' WHERE usercode='$usercode'";
	$updatemailnow = mysql_query($insertemail,$conn);
		if($updateemailnow){
		$action = "New Email added to subscribers list";
		$insertaction = "INSERT INTO actions(`id`,`action`,`date`,`ip`) VALUES('','$action','$date','$ip')";
		$actionsubmit = mysql_query($insertaction,$conn);
				if($actionsubmit){
				$contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.';
				}else{
				$contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.';
				}
		}else{
		$contentecho .='<li><font color="#FF0000">An error occurred with your verification. Please try again.</font></li>';
		}
	}else{
		foreach($validateerror as $errorkind){
		$contentecho .= ''.$errorkind.'';
		}
	}
break;
        case 'home':
$contentecho =''.$emailform.'';
        break;        
default:
$contentecho =''.$emailform.'';
break;
}
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Welcome!</title>

</head>
<body bgcolor="#999999" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<table width="750" height="0" cellpadding="0" cellspacing="0" border="0" style="Border: 1px solid #000000;">
<tr>
<td bgcolor="#666666" valign="top"><font color="#FFFFFF" face="arial"><b>Under construction</font></b></td>
</tr>
<tr>
<td bgcolor="#cccccc" valign="top">
<table width="98%" border="0">
        <font face="arial" size="3">
        Our website is under construction, bare with us as we create it.<b>Thanks for your consideration.</b><br>
<b>Check back soon!</b><br><br>
<i>The <?php echo $sitename; ?> Team</i></font>
</table>
</td>
</tr>
<tr>
<td bgcolor="#0099FF" valign="top"><font color="#FFFFFF" size="3" face="arial"><B>Sign up for email updates today!</B></font></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" valign="top">
<center>
<table width="98%" border="0">
<?php 	
echo $contentecho;
 ?>
</table>
</center>
</td>
</tr>
</table>
</center>
<h4 align="center">Our website is graciously hosted by <a href="http://guildwutang.com/">X ER Game Hosting</a></h4>
</body>
</html>

 

tthanks for any help possible,

 

HoTDaWg

Link to comment
Share on other sites

Ah, I'm guessing you upgraded PHP...because your error stems from the fact that you no longer have register_globals...

 

Change:

if (!isset($_GET['mode'])) {
$mode = "home";
}

 

To:

$mode = isset($_GET['mode']) && !empty($_GET['mode']) ? $_GET['mode'] : "home";

Link to comment
Share on other sites

:S thanks for the help, i am pretty sure i have register globals enabled... lemme double check....yea man i do.

 

ouch, check out the number of errors now ???

Notice: Undefined variable: email in /home/xdesigns/public_html/index.php on line 19

Notice: Undefined index: email in /home/xdesigns/public_html/index.php on line 20

Notice: Undefined variable: email in /home/xdesigns/public_html/index.php on line 22

Notice: Undefined variable: email in /home/xdesigns/public_html/index.php on line 25

Notice: Undefined variable: email in /home/xdesigns/public_html/index.php on line 28

Notice: Undefined variable: echoemailerrors in /home/xdesigns/public_html/index.php on line 59

Notice: Undefined index: text in /home/xdesigns/public_html/index.php on line 62

 

the code is now:

<?php
error_reporting(E_ALL);
$ip = $_SERVER['REMOTE_ADDR'];
$date = date('l, F j, Y @ g:i:s A e');
$sitename = "hahahaa";
$slogan = "hahahaa";
$subscribetext= "Join...NOW!";
$emailform = '<form method="POST" name="addsubscriber" action="http://www.hahahaa.com/index.php?mode=emailsubmit"><br>'.$subscribetext.'<br>Email:<input name="emailaddress" maxlength="80" value=""><br><input type="submit" value="Submit!"></form>';
$conn = mysql_connect("localhost","hahahaa","hahahaa");
mysql_select_db("hahahaa");
$adminemail = 'hahahaa';

$mode = isset($_GET['mode']) && !empty($_GET['mode']) ? $_GET['mode'] : "home";
$contentecho = array();
switch($mode){
case 'emailsubmit':
$emailerror = array();
	if(strlen($email) < 1){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email field was was not complete</font></li>';
	}
	if(strlen($email) > 80){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email field exeeds the limit of 80 characters</font></li>';
	}
	if(preg_match('|[^-_.@a-z\d]|i', $email)){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email Field contains invalid characters. Alphanumeric, @,-,and _ characters are the only characters accepted due to security reasons.</font></li>';
	}
	$emailexists = "SELECT email FROM subscribers WHERE email='$email'";
	$selectemailexists = mysql_query($emailexists,$conn);
		if(mysql_num_rows($selectemailexists) > 0){
		$emailerror['email'] .='<li><font color="#FF0000">This Email is already registered as a subscriber.</font></li>';
		}
	if(count($emailerror) < 1){
                $email = $_POST["emailaddress"];
	$usercode = rand(0,1000000);
	$status = 'blank';
	$insertemail = "INSERT INTO subscribers(`id`,`email`,`usercode`,`date`,`ip`,`status`) VALUES('','$email','$usercode','$date','$ip','$status')";
	$insertemailnow = mysql_query($insertemail,$conn);
		if($insertemailnow){
		$message="Thanks for registering on our website! Open a new window and go to http://www.hahahaa.com/index.php?email=$email&mode=verify&usercode=$usercode to complete your registration. Thanks.";
      		$to = &$email;
      		$subject = 'Validate This Email';
      		$headers = 'From: hahahaa' . "\r\n" .
      		'Reply-To: hahahaa' . "\r\n" .
//This statement helps out with spam filters
      		'X-Mailer: PHP/' . phpversion();
//Send the email
      		$mailnow = mail($to, $subject, $message, $headers,"bakhtawarawan@gmail.com");
			if($mailnow){
			$contentecho ='Thank you for registering. A verification email has been dispatched to your email address. Please check your spam/junk mail folders if the email does not appear in your inbox. If the email does not appear at all within 24 hours contact the administrator. Thanks again.';
			}else{
			$contentecho ='An error occurred with your submission. Please try again.';
			}
		}else{
		$contentecho ='An error occurred with your submission. Please try again.';
		}
	}else{
		foreach ($emailerror as $error){
		$echoemailerrors .= ''.$error.'';
		} 
	$content = array();
	$content['text'] .= 'The following errors were found in your submission:<br>'.$echoemailerrors.'<br>';
	$content['text'] .= ''.$emailform.'';
		foreach ($content as $text){
		$contentecho .= ''.$text.'';
		}
	}
break;
//BEGIN VERIFY
case 'verify':
$usercode = $_GET['usercode'];
$email = $_GET['email'];
$validateerror = array();
	if(empty($usercode) || empty($email)){
	$validateerror['empty'] .= '<li><font color="#FF0000">This page was accessed incorrectly.</font></li>';
	}
$validatetrue = "SELECT email,usercode FROM subscribtions WHERE email='$email' usercode='$usercode' status='good'";
$validatetruenow = mysql_query($validatetrue,$conn);
	if(mysql_num_rows($validatetruenow) > 0){
	$validateerror['already_exists'] .= '<li><font color="#FF0000">This email is already subscribed and validated.</font></li>';
	}
	if(count($validateerror) > 0){
	$status = "good";
	$updateemail = "UPDATE subscribers SET status='$status' WHERE usercode='$usercode'";
	$updatemailnow = mysql_query($insertemail,$conn);
		if($updateemailnow){
		$action = "New Email added to subscribers list";
		$insertaction = "INSERT INTO actions(`id`,`action`,`date`,`ip`) VALUES('','$action','$date','$ip')";
		$actionsubmit = mysql_query($insertaction,$conn);
				if($actionsubmit){
				$contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.';
				}else{
				$contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.';
				}
		}else{
		$contentecho .='<li><font color="#FF0000">An error occurred with your verification. Please try again.</font></li>';
		}
	}else{
		foreach($validateerror as $errorkind){
		$contentecho .= ''.$errorkind.'';
		}
	}
break;
        case 'home':
$contentecho =''.$emailform.'';
        break;        
default:
$contentecho =''.$emailform.'';
break;
}
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Welcome!</title>

</head>
<body bgcolor="#999999" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<table width="750" height="0" cellpadding="0" cellspacing="0" border="0" style="Border: 1px solid #000000;">
<tr>
<td bgcolor="#666666" valign="top"><font color="#FFFFFF" face="arial"><b>Under construction</font></b></td>
</tr>
<tr>
<td bgcolor="#cccccc" valign="top">
<table width="98%" border="0">
        <font face="arial" size="3">
        Our website is under construction, bare with us as we create it.<b>Thanks for your consideration.</b><br>
<b>Check back soon!</b><br><br>
<i>The <?php echo $sitename; ?> Team</i></font>
</table>
</td>
</tr>
<tr>
<td bgcolor="#0099FF" valign="top"><font color="#FFFFFF" size="3" face="arial"><B>Sign up for email updates today!</B></font></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" valign="top">
<center>
<table width="98%" border="0">
<?php 	
echo $contentecho;
 ?>
</table>
</center>
</td>
</tr>
</table>
</center>
<h4 align="center">Our website is graciously hosted by <a href="http://guildwutang.com/">X ER Game Hosting</a></h4>
</body>
</html>

Link to comment
Share on other sites

Guest prozente

first things first, register globals isn't good to use.

second, use isset

 

for example line 19

 

if(strlen($email) < 1){

 

should be

 

if(isset($email) && strlen($email) < 1){

 

line 20 you have

 

$emailerror['email'] .= '<li><font color="#FF0000">The Email field was was not complete</font></li>';

 

to fix this add to the beginning of your script

 

$emailerror['email'] = '';

 

this should help you understand the other errors

Link to comment
Share on other sites

first things first, register globals isn't good to use.

second, use isset

 

for example line 19

 

if(strlen($email) < 1){

 

should be

 

if(isset($email) && strlen($email) < 1){

 

line 20 you have

 

$emailerror['email'] .= '<li><font color="#FF0000">The Email field was was not complete</font></li>';

 

to fix this add to the beginning of your script

 

$emailerror['email'] = '';

 

this should help you understand the other errors

im sorry, but i do not quite understand what adding

<?php
$emailerror['email'] = ''
?>

would do...Would someone please explain for me?

 

thanks and sorry,

 

HoTDaWg

Link to comment
Share on other sites

Guest prozente

because of these type of lines in your code

 

$emailerror['email'] .= '<li><font color="#FF0000">The Email field was was not complete</font></li>';

 

.= means to append to the end of the existing variable, but in your case it doesn't exist so you are causing the warning message

Link to comment
Share on other sites

okay,

 

thanks so much for the in-depth explanation and help. No errors...the problem is that upon pressing submit all it says is:

The Email field was was not complete

 

the code is now:

<?php
error_reporting(E_ALL);
$ip = $_SERVER['REMOTE_ADDR'];
$date = date('l, F j, Y @ g:i:s A e');
$sitename = "*****";
$slogan = "*****";
$subscribetext= "Join...NOW!";
$emailform = '<form method="POST" name="addsubscriber" action="http://www.*****.com/index.php?mode=emailsubmit"><br>'.$subscribetext.'<br>Email:<input name="emailaddress" maxlength="80" value=""><br><input type="submit" value="Submit!"></form>';
$conn = mysql_connect("localhost","*****","*****");
mysql_select_db("*****");
$adminemail = '*****@*****.com';

$mode = isset($_GET['mode']) && !empty($_GET['mode']) ? $_GET['mode'] : "home";

$contentecho = array();
switch($mode){
case 'emailsubmit':
$emailerror = array();
$email = isset($_POST['mode']) && !empty($_POST['mode']);
	if(isset($email) && strlen($email) < 1){
	$emailerror['email'] = '<li><font color="#FF0000">The Email field was was not complete</font></li>';
	}
	if(strlen($email) > 80){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email field exeeds the limit of 80 characters</font></li>';
	}
	if(isset($email) && preg_match('|[^-_.@a-z\d]|i', $email)){
	$emailerror['email'] .= '<li><font color="#FF0000">The Email Field contains invalid characters. Alphanumeric, @,-,and _ characters are the only characters accepted due to security reasons.</font></li>';
	}
	$emailexists = "SELECT email FROM subscribers WHERE email='$email'";
	$selectemailexists = mysql_query($emailexists,$conn);
		if(mysql_num_rows($selectemailexists) > 0){
		$emailerror['email'] .='<li><font color="#FF0000">This Email is already registered as a subscriber.</font></li>';
		}
	if(count($emailerror) < 1){
	$usercode = rand(0,1000000);
	$status = 'blank';
	$insertemail = "INSERT INTO subscribers(`id`,`email`,`usercode`,`date`,`ip`,`status`) VALUES('','$email','$usercode','$date','$ip','$status')";
	$insertemailnow = mysql_query($insertemail,$conn);
		if($insertemailnow){
		$message="Thanks for registering on our website! Open a new window and go to http://www.*****.com/index.php?email=$email&mode=verify&usercode=$usercode to complete your registration. Thanks.";
      		$to = &$email;
      		$subject = 'Validate This Email';
      		$headers = 'From: *****@*****.com' . "\r\n" .
      		'Reply-To: *****@*****.com' . "\r\n" .
//This statement helps out with spam filters
      		'X-Mailer: PHP/' . phpversion();
//Send the email
      		$mailnow = mail($to, $subject, $message, $headers,"bakhtawarawan@gmail.com");
			if($mailnow){
			$contentecho ='Thank you for registering. A verification email has been dispatched to your email address. Please check your spam/junk mail folders if the email does not appear in your inbox. If the email does not appear at all within 24 hours contact the administrator. Thanks again.';
			}else{
			$contentecho ='An error occurred with your submission, the verification email was not sent. Please try again.';
			}
		}else{
		$contentecho ='An error occurred with your submission. Please try again.';
		}
	}else{
		foreach ($emailerror as $error){
		$echoemailerrors = ''.$error.'';
		} 
	$content = array();
	$content['text'] = 'The following errors were found in your submission:<br>'.$echoemailerrors.'<br>';
	$content['text'] .= ''.$emailform.'';
		foreach ($content as $text){
		$contentecho = ''.$text.'';
		}
	}
break;
//BEGIN VERIFY
case 'verify':
$usercode = $_GET['usercode'];
$email = $_GET['email'];
$validateerror = array();
	if(empty($usercode) || empty($email)){
	$validateerror['empty'] .= '<li><font color="#FF0000">This page was accessed incorrectly.</font></li>';
	}
$validatetrue = "SELECT email,usercode FROM subscribtions WHERE email='$email' usercode='$usercode' status='good'";
$validatetruenow = mysql_query($validatetrue,$conn);
	if(mysql_num_rows($validatetruenow) > 0){
	$validateerror['already_exists'] .= '<li><font color="#FF0000">This email is already subscribed and validated.</font></li>';
	}
	if(count($validateerror) > 0){
	$status = "good";
	$updateemail = "UPDATE subscribers SET status='$status' WHERE usercode='$usercode'";
	$updatemailnow = mysql_query($insertemail,$conn);
		if($updateemailnow){
		$action = "New Email added to subscribers list";
		$insertaction = "INSERT INTO actions(`id`,`action`,`date`,`ip`) VALUES('','$action','$date','$ip')";
		$actionsubmit = mysql_query($insertaction,$conn);
				if($actionsubmit){
				$contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.';
				}else{
				$contentecho .='Your email has been successfully added to our subscribers list. Expect a newsletter soon! Thank you for your interest.';
				}
		}else{
		$contentecho .='<li><font color="#FF0000">An error occurred with your verification. Please try again.</font></li>';
		}
	}else{
		foreach($validateerror as $errorkind){
		$contentecho .= ''.$errorkind.'';
		}
	}
break;
        case 'home':
$contentecho =''.$emailform.'';
        break;        
default:
$contentecho =''.$emailform.'';
break;
}
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Welcome!</title>

</head>
<body bgcolor="#999999" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<table width="750" height="0" cellpadding="0" cellspacing="0" border="0" style="Border: 1px solid #000000;">
<tr>
<td bgcolor="#666666" valign="top"><font color="#FFFFFF" face="arial"><b>Under construction</font></b></td>
</tr>
<tr>
<td bgcolor="#cccccc" valign="top">
<table width="98%" border="0">
        <font face="arial" size="3">
        Our website is under construction, bare with us as we create it.<b>Thanks for your consideration.</b><br>
<b>Check back soon!</b><br><br>
<i>The <?php echo $sitename; ?> Team</i></font>
</table>
</td>
</tr>
<tr>
<td bgcolor="#0099FF" valign="top"><font color="#FFFFFF" size="3" face="arial"><B>Sign up for email updates today!</B></font></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" valign="top">
<center>
<table width="98%" border="0">
<?php 	
echo $contentecho;
 ?>
</table>
</center>
</td>
</tr>
</table>
</center>
<h4 align="center">Our website is graciously hosted by <a href="http://guildwutang.com/">X ER Game Hosting</a></h4>
</body>
</html>

???

 

any help would be greatly appreciated thanks...

 

HoTDaWg

Link to comment
Share on other sites

haha, thanks thank you so much prozente.

 

although i really do regret this...

but i am still having one problem

 

the only error which comes up now is

The Email field was was not complete

the other errors like the one for having invalid characters etc...do not come up. nothing inserts into the database and no email is sent...any ideas....

 

???

 

thanks so much,

 

HoTDaWg

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.