HoTDaWg Posted April 14, 2007 Share Posted April 14, 2007 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 https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/ Share on other sites More sharing options...
AndyB Posted April 14, 2007 Share Posted April 14, 2007 Warning: undefined index mode is NOT an error, it's a warning. And if there's a reported syntax error at line 18, which line is that? The error is on that line or one of the preceding lines. Link to comment https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229237 Share on other sites More sharing options...
HoTDaWg Posted April 14, 2007 Author Share Posted April 14, 2007 i understand it is a warning, but why is it giving that? and line 18 is: <?php ... $contentecho = array(); ... ?> any ideas? thanks HoTDaWg Link to comment https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229250 Share on other sites More sharing options...
kenrbnsn Posted April 14, 2007 Share Posted April 14, 2007 You're getting the error message because line 17 is a "switch" statement, so you can't have a plain line there. Move line 18 to before line 17. Ken Link to comment https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229252 Share on other sites More sharing options...
HoTDaWg Posted April 14, 2007 Author Share Posted April 14, 2007 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,"[email protected]"); 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 https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229258 Share on other sites More sharing options...
Glyde Posted April 14, 2007 Share Posted April 14, 2007 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 https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229272 Share on other sites More sharing options...
HoTDaWg Posted April 14, 2007 Author Share Posted April 14, 2007 :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,"[email protected]"); 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 https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229371 Share on other sites More sharing options...
HoTDaWg Posted April 15, 2007 Author Share Posted April 15, 2007 any Ideas? Link to comment https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229461 Share on other sites More sharing options...
Guest prozente Posted April 15, 2007 Share Posted April 15, 2007 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 https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229464 Share on other sites More sharing options...
HoTDaWg Posted April 15, 2007 Author Share Posted April 15, 2007 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 https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229473 Share on other sites More sharing options...
Guest prozente Posted April 15, 2007 Share Posted April 15, 2007 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 https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229475 Share on other sites More sharing options...
HoTDaWg Posted April 15, 2007 Author Share Posted April 15, 2007 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,"[email protected]"); 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 https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229511 Share on other sites More sharing options...
Guest prozente Posted April 15, 2007 Share Posted April 15, 2007 probably because of this.. $email = isset($_POST['mode']) && !empty($_POST['mode']); You should see the problem now Link to comment https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229516 Share on other sites More sharing options...
HoTDaWg Posted April 15, 2007 Author Share Posted April 15, 2007 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 https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229518 Share on other sites More sharing options...
HoTDaWg Posted April 15, 2007 Author Share Posted April 15, 2007 sorry but it has been a while since i have been waiting can anyone help me? any assistance would be greatly appreciated HoTDaWg Link to comment https://forums.phpfreaks.com/topic/47004-indexphp-long-php-script-was-barely-functioing-now-not-at-all/#findComment-229964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.