HoTDaWg Posted April 2, 2007 Share Posted April 2, 2007 Take a look at this: <?php error_reporting(E_ALL); $ip = $_SERVER['REMOTE_ADDR']; $date = date('l, F J, Y @ g:i:s A e'); $sitename = "*****"; $slogan = "*****"; $subscribetext= "*****"; $emailform = '<form method="POST" name="addsubscriber" action="*****/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 = '*****'; define('inStereo',true); $mode=$_GET["mode"]; if(!empty($mode)){ switch($mode){ case 'emailsubmit': $email = $_POST['emailaddress']; $emailerror = array(); if(empty($email)){ $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://*****/index.php?email=$email&mode=verify&usercode=$usercode to complete your registration. Thanks."; $to = &$email; $subject = 'Validate This Email'; $headers = 'From: *****' . "\r\n" . 'Reply-To: *****' . "\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; default: $contentecho =''.$emailform.''; break; } }else{ $contentecho =''.$emailform.''; } ?> <!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> its weird, i immedietely get the following error: Notice: Undefined index: mode in /home/xdesigns/public_html/index.php on line 14 thanks for any help possible, HoTDaWg Link to comment https://forums.phpfreaks.com/topic/45319-basic-function-weird-behaviour/ Share on other sites More sharing options...
emehrkay Posted April 2, 2007 Share Posted April 2, 2007 is mode set in the url? Link to comment https://forums.phpfreaks.com/topic/45319-basic-function-weird-behaviour/#findComment-220025 Share on other sites More sharing options...
HoTDaWg Posted April 2, 2007 Author Share Posted April 2, 2007 :| no, your right...its not. how can i make so that it is? thanks HoTDaWg Link to comment https://forums.phpfreaks.com/topic/45319-basic-function-weird-behaviour/#findComment-220031 Share on other sites More sharing options...
emehrkay Posted April 2, 2007 Share Posted April 2, 2007 when you link someone to that page do page.php?mode=emailsubmit if this page is linked from a from, replace $_GET with $_POST and make srue you set the mode val on the form Link to comment https://forums.phpfreaks.com/topic/45319-basic-function-weird-behaviour/#findComment-220047 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.