ballhogjoni Posted November 15, 2007 Share Posted November 15, 2007 For some reason my code is not working. I mean that when someone enters their info in the fields (not shown in code below) it stops at the first part: if ($action == "sub") { echo $emailPost; It will not move on to any other part of the script. Can some one help me out. Thx. <?php if ($action == "sub") { echo $emailPost; if (empty($emailPost)) { echo("Please enter an email address! <a href=\"index.php\">Go back</a>.<br />"); } else { $res = mysql_query("SELECT * FROM newsblitz_list WHERE email_addr = '".$emailPost."'") or die(mysql_error()); $row = mysql_fetch_array($res) or die(mysql_error()); if ($row['email_addr'] == $emailPost && $row['gets_mail'] == 1) { echo("<strong>$emailPost</strong> is already subscribed to $news_name! <a href=\"index.php\">Go back</a>.<br />"); } else { if ($row['email_addr'] != $emailPost) { $date = Date('m/d/y h:ia'); $query = "INSERT INTO newsblitz_list (fname,email_addr,date_subscribed,gets_mail) VALUES ('$name','$emailPost','$date','0')"; $res = mysql_query($query) or die(mysql_error()); $name = $_POST['name']; $confurl = "http://nnnnnn.com/mailer/index.php?action=conf&addr=$id,".md5($emailPost); $subject = "[$news_name] Newsletter Confirmation"; $message = "$name,\n\nSomebody (hopefully you) has chosen to subscribe this email address to $news_name.\n\nIf you would like to receive our newsletter, then please confirm your subscription by going to the confirmation URL below. Otherwise, you can safely disregard this message.\n\nThanks,\n$admin_email\n\nConfirmation URL: $confurl\n"; $from = $from_email; $headers = "From: $from"; mail($emailPost,$subject,$message,$headers); echo("<strong>$emailPost</strong> has been subscribed to $news_name. Please check your inbox; you'll receive an email shortly to confirm your subscription. <a href=\"index.php\">Go back</a>.<br />"); } else { $id = $row['id']; $date = Date('m/d/y h:ia'); $confurl = "http://nnnnnnnnnnn.com/mailer/index.php?action=conf&addr=$id,".md5($emailPost); $subject = "[$news_name] Newsletter Confirmation"; $message = "$name,\n\nSomebody (hopefully you) has chosen to subscribe this email address to $news_name.\n\nIf you would like to receive our newsletter, then please confirm your subscription by going to the confirmation URL below. Otherwise, you can safely disregard this message.\n\nThanks,\n$admin_email\n\nConfirmation URL: $confurl\n"; $from = $from_email; $headers = "From: $from"; mail($from,$subject,$message,$headers); echo("<strong>$emailPost</strong> has been subscribed to $news_name. Please check your inbox; you'll receive an email shortly to confirm your subscription. <a href=\"index.php\">Go back</a>.<br />"); } } } } ?> Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 15, 2007 Share Posted November 15, 2007 Try <?php if ($_POST['action'] == "sub") { Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 15, 2007 Share Posted November 15, 2007 Try this...this will tell you exactly what IF statement is giving you problems, post what you get. <?php if ($action == "sub") { echo $emailPost; if (empty($emailPost)) { echo("Please enter an email address! <a href=\"index.php\">Go back</a>.<br />"); } else { $res = mysql_query("SELECT * FROM newsblitz_list WHERE email_addr = '".$emailPost."'") or die(mysql_error()); $row = mysql_fetch_array($res) or die(mysql_error()); if ($row['email_addr'] == $emailPost && $row['gets_mail'] == 1) { echo("<strong>$emailPost</strong> is already subscribed to $news_name! <a href=\"index.php\"> Go back</a>.<br />"); } else { if ($row['email_addr'] != $emailPost) { $date = Date('m/d/y h:ia'); $query = "INSERT INTO newsblitz_list (fname,email_addr,date_subscribed,gets_mail) VALUES ('$name','$emailPost','$date','0')"; $res = mysql_query($query) or die(mysql_error()); $name = $_POST['name']; $confurl = "http://nnnnnn.com/mailer/index.php?action=conf&addr=$id,".md5($emailPost); $subject = "[$news_name] Newsletter Confirmation"; $message = "$name,\n\nSomebody (hopefully you) has chosen to subscribe this email address to $news_name.\n\nIf you would like to receive our newsletter, then please confirm your subscription by going to the confirmation URL below. Otherwise, you can safely disregard this message. \n\nThanks,\n$admin_email\n\nConfirmation URL: $confurl\n"; $from = $from_email; $headers = "From: $from"; mail($emailPost,$subject,$message,$headers); echo("<strong>$emailPost</strong> has been subscribed to $news_name. Please check your inbox; you'll receive an email shortly to confirm your subscription. <a href=\"index.php\">Go back</a>.<br />"); } else { $id = $row['id']; $date = Date('m/d/y h:ia'); $confurl = "http://nnnnnnnnnnn.com/mailer/index.php?action=conf&addr=$id,".md5($emailPost); $subject = "[$news_name] Newsletter Confirmation"; $message = "$name,\n\nSomebody (hopefully you) has chosen to subscribe this email address to $news_name.\n\nIf you would like to receive our newsletter, then please confirm your subscription by going to the confirmation URL below. Otherwise, you can safely disregard this message. \n\nThanks,\n$admin_email\n\nConfirmation URL: $confurl\n"; $from = $from_email; $headers = "From: $from"; mail($from,$subject,$message,$headers); echo("<strong>$emailPost</strong> has been subscribed to $news_name. Please check your inbox; you'll receive an email shortly to confirm your subscription. <a href=\"index.php\">Go back</a>.<br />"); } else { echo "I don't think you will get this one..."; } } else { echo '($row[email_addr] == $emailPost && $row[gets_mail] == 1) not working right...'; } } else { echo "I hope you dont' get this error..."; } } else { echo '$action == "sub" not set'; } ?> Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted November 16, 2007 Author Share Posted November 16, 2007 After this: <?php if ($action == "sub") { echo $emailPost; if (empty($emailPost)) { echo("Please enter an email address! <a href=\"index.php\">Go back</a>.<br />"); } else { ?> is the problem. Problem code: <?php $res = mysql_query("SELECT * FROM newsblitz_list WHERE email_addr = '".$emailPost."'") or die(mysql_error()); $row = mysql_fetch_array($res) or die(mysql_error()); if ($row['email_addr'] == $emailPost && $row['gets_mail'] == 1) { echo("<strong>$emailPost</strong> is already subscribed to $news_name! <a href=\"index.php\">Go back</a>.<br />"); } else { if ($row['email_addr'] != $emailPost) { $date = Date('m/d/y h:ia'); $query = "INSERT INTO newsblitz_list (fname,email_addr,date_subscribed,gets_mail) VALUES ('$name','$emailPost','$date','0')"; $res = mysql_query($query) or die(mysql_error()); $name = $_POST['name']; $confurl = "http://nnnnnn.com/mailer/index.php?action=conf&addr=$id,".md5($emailPost); $subject = "[$news_name] Newsletter Confirmation"; $message = "$name,\n\nSomebody (hopefully you) has chosen to subscribe this email address to $news_name.\n\nIf you would like to receive our newsletter, then please confirm your subscription by going to the confirmation URL below. Otherwise, you can safely disregard this message.\n\nThanks,\n$admin_email\n\nConfirmation URL: $confurl\n"; $from = $from_email; $headers = "From: $from"; mail($emailPost,$subject,$message,$headers); echo("<strong>$emailPost</strong> has been subscribed to $news_name. Please check your inbox; you'll receive an email shortly to confirm your subscription. <a href=\"index.php\">Go back</a>.<br />"); } else { $id = $row['id']; $date = Date('m/d/y h:ia'); $confurl = "http://nnnnnnnnnnn.com/mailer/index.php?action=conf&addr=$id,".md5($emailPost); $subject = "[$news_name] Newsletter Confirmation"; $message = "$name,\n\nSomebody (hopefully you) has chosen to subscribe this email address to $news_name.\n\nIf you would like to receive our newsletter, then please confirm your subscription by going to the confirmation URL below. Otherwise, you can safely disregard this message.\n\nThanks,\n$admin_email\n\nConfirmation URL: $confurl\n"; $from = $from_email; $headers = "From: $from"; mail($from,$subject,$message,$headers); echo("<strong>$emailPost</strong> has been subscribed to $news_name. Please check your inbox; you'll receive an email shortly to confirm your subscription. <a href=\"index.php\">Go back</a>.<br />"); } } } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.