23, November 2008

Can someone help re-write code for $ ? - problem with if/else statements - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Can someone help re-write code for $ ? - problem with if/else statements
« previous next »
Pages: [1] Print

Author Topic: Can someone help re-write code for $ ? - problem with if/else statements  (Read 614 times)
My Name is Enigo Montoya
*
Posts: 33
188 credits
Members referred : 0


« on: Mar 22, 2008, 02:48:22 AM »

Everything works as far as both mail formats being sent, but I am trying to add validation to it so it checks that the fields aren't blank before the mail is sent.  A lot of this is existing code that I am working with to modify, so it does reference possibly an older version of php(things such as $HTTP_POST_VARS)  The validation code at the top, is used in several other pages, so I am just using it here.  The validation shows correctly, but my problem is that after the errors are echo'ed the rest of the code is executed which sends blank mail.  The code between the #####'s is all the code that prepares the mail and sends it.

I don't mind to donate to anyone that might be able to help.

Code:
<p id="sectionTitle"><?php echo PAGETITLE_SEND_NEWSLETTER ?></p>
<p><a href="index.php?page=../massemail/mass_email_admin_menu" class="linkBg">« Back</a></p>
<?php 
require_once "../include/Validator.php"
if (
$HTTP_POST_VARS){ 
$validator = new Validator(); 
$validator->validateGeneral($HTTP_POST_VARS['subject'], NEWSLETTER_VAL_SUBJECT); 
$validator->validateGeneral($HTTP_POST_VARS['text_message'], NEWSLETTER_VAL_TEXT); 
$validator->validateGeneral($HTTP_POST_VARS['fckeditor'], NEWSLETTER_VAL_EDITOR); 
if ( 
$validator->foundErrors() ){ 
echo 
'<b style="color:#C92E2A; font-size:12px;"> 'ERROR_PLEASE_INSERT .' </b> <br /><i>'.$validator->listErrors('<br>').'</i><br><br /><br /><br /> <a href="index.php?page=../massemail/new2" class="linkBg">« Back - show form again</a>'
}else{ 
//echo "<p><a href=\"index.php?page=../massemail/new2\" class=\"linkBg\">« Back - show form again</a></p>"; 


?>

<?php 
require_once 'system_data.php'
$query "select fname,email from newsletter where status='1'"
$result mysql_query($query) or die(mysql_error()); 

if (
== mysql_num_rows($result)) 

echo 
"<p>".SEND_NEWSLETTER_EMPTY_SUBSCRIBERS_LIST."</p>"

else 

if (isset(
$_POST['submit'])) 


while (list(
$full_name,$email) = mysql_fetch_row($result)) 


################################################## 
// load email class definition. 

include('class.Email.php'); 

// establish to,from, and any other recipiants. 

$Sender ""$site_name "<" $admin_email ">"
$Cc ""
$Bcc ""

// create the text and HTML versions of the body content here. 

$textVersion "Dear " stripslashes(str_replace('_'' '$full_name)) . ",\n\r"
$textVersion .= stripslashes($_POST['text_message']); 
$textVersion .="\n\r----- *** Notice *** -----\n\r"
$textVersion .= "If you don't wish to receive our newsletter anymore, please click the link below for safe and permanent unsubscription.\n\r"
$textVersion .= $websiteUrl "/massemail/confirm.php?action=remove&email=" $email

$htmlVersion "<html>"
$htmlVersion .= "<head>"
$htmlVersion .= "Dear " stripslashes(str_replace('_'' '$full_name)) . ",<br><br>\r\n\r\n"
$htmlVersion .= $_POST['fckeditor']; 
$htmlVersion .="<br><br>----- *** Notice *** -----<br><br>\r\n\r\n"
$htmlVersion .= "If you don't wish to receive our newsletter anymore, please click the link below for safe and permanent unsubscription.<br><br>\r\n\r\n"
$htmlVersion .= "<a href='$websiteUrl/massemail/confirm.php?action=remove&email=$email'>$websiteUrl/massemail/confirm.php?action=remove&email=$email</a>"
$htmlVersion .= "</html>"

unset(
$msg); 

// ! SEND A MULTIPART/ALTERNATIVE EMAIL ! 
// create the new message using the to, from, and email subject. 

////// $msg = new Email($email, stripslashes($_POST['subject']). " - " . date("l \\t\h\e jS")); 
$msg = new Email($email$Senderstripslashes($_POST['subject'])); 
$msg->Cc $Cc
$msg->Bcc $Bcc

// set the message to be a multiprat/alternative email. This allows for multiple versions of same content.  

$msg->SetMultipartAlternative($textVersionstripslashes($htmlVersion)); 

// send the email message. 

$SendSuccess $msg->Send(); 

echo 
"Multipart/alternative email was "
(
$SendSuccess "sent" "not sent"), "<br>"

##################################################  


echo 
"<b>".SEND_NEWSLETTER_SUCCESS."</b>"

else 

?>

<?php print "" $_POST['fckeditor'] . "" ?>
<form action="<?php "" .$_SERVER['PHP_SELF']. "" ?>" method="post">
<p><b><?php echo SEND_NEWSLETTER_SUBJECT ?></b><br />
<input type='text' name='subject' size="65" class="field" />
<input type='hidden' name='action' value="send" />
</p>Text Version:<br /><textarea autocomplete="off" name="text_message" style="width: 100%; height: 200px"></textarea>
<p><b><?php echo SEND_NEWSLETTER_MESSAGE ?> </b><br />
<?php 
include("FCKeditor/fckeditor.php") ; 
?>

<?php 
$oFCKeditor 
= new FCKeditor('fckeditor') ; 
$oFCKeditor->BasePath './FCKeditor/'
$oFCKeditor->Value $text
$oFCKeditor->Create() ; 
?>
</p>
<p class="submit"><input type='submit' name='submit' value='<?php echo BUTTON_SEND_NEWSLETTER ?>' class="buttons" /></p>
</form>
<?php 


?>

Thank you!
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Mar 22, 2008, 08:43:46 AM »

look maybe your mailscript has genertated some error, use products like tinymce (fuckeditor sucks) and phpmailer to be safe that your scripts are fine.

enable error_reporting too (this problem is not some if/else statement)


Last blog : Just a better Internet portal provided by Google
My Name is Enigo Montoya
*
Posts: 33
188 credits
Members referred : 0


« Reply #2 on: Mar 23, 2008, 04:28:47 AM »

This is very true Olaf...(fuckeditor sucks)  Grin  Very buggy at times I have noticed.  I'll have to ask my client again why they like it so much...maybe they think it looks nice...LOL  I'll see what I can come up with, thanks!
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6441
39470 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Mar 23, 2008, 09:43:11 AM »

I think if you change it too tinymce and you tell the customer it's a new version he will never notice Cheesy

try a different mail script first to find the bug...


Last blog : Just a better Internet portal provided by Google
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7668
Tags : validation error if/else newsletter Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Can someone help re-write code for $ ? - problem with if/else statements
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Nov 23, 2008, 02:33:27 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 37.756
Total Topics: 7.652
Total Members: 4.400
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: GregH

34 Guests, 4 Users online :

11 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.