The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP4 - Emailer
Discuss Emailer in the PHP Development forum on Dev Shed. Emailer PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 27th, 2012, 03:44 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 1 h 29 m 42 sec
Reputation Power: 0
|
|
|
PHP4 - Emailer
hi
i have a problem running a while loop in a emailer. i need to send the email a number of times. on the email is a voucher, each time one is created the barcode on each must change.
|

November 27th, 2012, 04:04 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
|
Hi,
well, that's interesting, but what are we supposed to do now?
We're not psychic. We cannot magically find your problem based on a vague description of your script. If you want us to help, we need the actual code and a concrete error description (including any error message).
|

November 27th, 2012, 04:16 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 1 h 29 m 42 sec
Reputation Power: 0
|
|
|
can i email the code to you? i cant post it here, it gives an message bout [php] and stuff.....
|

November 27th, 2012, 04:30 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 1 h 29 m 42 sec
Reputation Power: 0
|
|
|
[PHP
include("a_connect.php");
$uid = (!empty($_GET['uid']))?$_GET['uid']:"";
$v = (!empty($_GET['v']))?$_GET['v']:"";
//switch($v){
//case "print":
//header("location:../generate-ticket3.php?uid=".$uid);
//break;
//case "email":
$i = 1;
$counter = $_POST["counter"]; // counter is set in the form, the page before coming to this page
while ($i <= $counter):
$row = row("select * from city_ticketsbought where bought_uid='$uid'");
$barcode = $row->bought_barcode;
$voucher = $row->bought_voucher;
$name = $row->bought_name;
$date = $row->bought_date;
$email = $row->bought_email;
$todaydate = date('d M Y');
$fromaddress = "email";
$Subject ="Voucher Confirmation";
$mailHeader = "From: " . $fromaddress;
$theMessage="";
$theMessage.="";
$theMessage.="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><title>City Sightseeing</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
$theMessage.="<style type=\"text/css\">";
$theMessage.="<!--";
$theMessage.="body, table, div, p {font-family: Arial, Helvetica, sans-serif;font-size:12px;}";
$theMessage.="-->";
$theMessage.="</style></head>";
$theMessage.="<body><table width=\"576\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
$theMessage.="<tr><td colspan=\"2\" style='background:#de011b;'><img src='".$theURL."images/city-sightseeing_icon.jpg' width='110' height='130' /><img src='".$theURL."images/city-sightseeing.gif' width='229' height='130' /></td>";
$theMessage.="</tr><tr>";
$theMessage.="<td valign=\"top\"><br>";
$theMessage.="<table width='576'><tr><td valign='top'><br><strong>Dear ".$name."</strong><br /></td><td align='right' width='200'>".$date ."<br>#".$barcode."<br>".$voucher."</td></tr>";
$theMessage.="</table>";
$theMessage.= "<br><a href='".$theURL."voucher.php?uid=".$uid."' target='_blank'>Print My Voucher</a><br /><br /><hr style=\"border-top:1px solid #000000;margin:10px 0px 10px 0px;\">";
$theMessage.="<div style=\"font-size:9px;line-height:10px;\"></div></td>";
$theMessage.="<td align=\"right\" valign=\"top\"></td>";
$theMessage.="</tr><tr><td colspan=\"2\" valign=\"top\"><br>";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$mailHeader.= "\nMIME-Version: 1.0\n" .
"Content-Type: text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n";
$toaddress = $email;
$ok = mail($toaddress, $Subject, $theMessage, $mailHeader);
$toaddress = "gaston@web2web.co.za";
$ck = mail($toaddress, $Subject, $theMessage, $mailHeader);
/**/
echo("<div style='margin:20px auto 0px auto;color:#FFF;font-family:arial;font-size:14px;text-align:center;padding:40px;width:700px;background:#ff0000'>The voucher email has been sent to $email</div>");
$i++;
endwhile;
]
|

November 27th, 2012, 04:44 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
|
OK. And what's your question?
|

November 27th, 2012, 04:48 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 1 h 29 m 42 sec
Reputation Power: 0
|
|
|
I have to loop this a number of times (the user must enter how many times). Then the form must print that amount of times. but the barcode after every loop should be different.
|

November 27th, 2012, 05:06 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
Quote: | Originally Posted by Gaston Then the form must print that amount of times. |
So? Just print $_POST["counter"].
If you want to count the number of successful mails, use a separate counter that will only increment if $ok is true.
Quote: | Originally Posted by Gaston but the barcode after every loop should be different. |
Not sure what you're trying to do. As far as I can tell, the barcode comes from $row:
PHP Code:
$row = row("select * from city_ticketsbought where bought_uid='$uid'");
$barcode = $row->bought_barcode;
But you always select the same (random) row in each loop run, so the bar code is always the same.
If that's not what you want, then what do you want? You have multiple tickets (?) with each one having its own barcode, and you have a counter which is specified by the user. What is supposed to happen now?
|

November 27th, 2012, 05:22 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 1 h 29 m 42 sec
Reputation Power: 0
|
|
|
i cant get it to send the email when i run the while loop. when i take the while out, it just send one email. i need it to send a number of times the user wants it to. the loop is not working at this moment
|

November 27th, 2012, 05:43 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
Quote: | Originally Posted by Gaston the loop is not working at this moment |
Um, and how were we supposed to know that?
Check if $_POST["counter"] is correct with var_dump($_POST) and reduce the loop to the absolute minimum (just do something like echo $i).
Also make sure you got your error_reporting turned on:
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|