|
Posted by Carl on 12/29/05 03:42
Leszek wrote:
> Yes so maybe the problem is somewhere else...
>
> here are my scripts
> // zawiadomienie.php
> <?php
> $tresc1="
> <b>Thanks you entered:<br />
> {$_POST['$title']} {$_POST['$first_name']} {$_POST['$family_name']} <br />
> {$_POST['$gender']} <br />
> {$_POST['$address']} <br />
> {$_POST['$pcode']} {$_POST['$city']} {$_POST['$country']} <br />
> {$_POST['$phone']} <br />
> {$_POST['$fax']}<br />
> {$_POST['$email']}<br />
> Names of accompanying porsons:</b><br />";
> echo"<b><p>";
>
> for ($i=1;$i<=5;$i++){
> $osoba=$_POST["name"."$i"];
> if (strlen($osoba)>0){
> echo $osoba;
> echo "<br>";
> }
> }
> echo "</p></b>";
> $tresc2="
> <b>Nowy uczestnik konferencji zarejestrowal sie w bazie danych: </b><br
> /><br />
> Title: <b>{$_POST['$title']}</b> <br />
> Family Name: <b>{$_POST['$family_name']}</b><br />
> First Name: <b>{$_POST['$first_name']}</b><br />
> Gender: <b>{$_POST['$gender']}</b><br />
> Address: <b>{$_POST['$address']}</b> <br />
> Postal Code: <b>{$_POST['$pcode']}</b><br />
> City: <b>{$_POST['$city']}</b><br />
> Country: <b>{$_POST['$country']}</b><br />
> Phone: <b>{$_POST['$phone']}</b><br />
> Fax: <b>{$_POST['$fax']}</b><br />
> Email: <b>{$_POST['$email']}</b><br />
> <br />
> Accompanying persons are:<br />";
> echo"<b>";
> for ($i=1;$i<=5;$i++){
> $osoba=$_POST["name"."$i"];
> if (strlen($osoba)>0){
> echo $osoba;
> echo "<br>";
> }
> }
> echo "</b>";
> ?>
> // end of zawiadomienie.php
>
>
> // wyslij_zaw.php
> <?php
> require("class.phpmailer.php");
>
> $mail = new PHPMailer();
> $mail->IsSMTP(); // set mailer to use
> SMTP
> $mail->Host ="smtp.poczta.onet.pl"; // specify main and backup server
> $mail->SMTPAuth = true; // turn on SMTP authentication
> $mail->Username ="user"; // SMTP username
> $mail->Password ="password"; // SMTP password
>
> $mail->From ="leszekt80@poczta.onet.pl";
> $mail->FromName ="{$_POST['$family_name']}";
> $mail->AddAddress("leszekt80@poczta.onet.pl","EMBRYO");
> #$mail->AddAddress("ellen@example.com"); // name is
> optional
> #$mail->AddReplyTo("info@example.com", "Information");
> # $mail->WordWrap = 50; // set word wrap to
> 50 characters
> # $mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
> # $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
> $mail->IsHTML(true); // set email format to
> HTML
>
> $mail->Subject = "Registration";
> $mail->Body = "$tresc2";
> #$mail->AltBody = "This is the body in plain text for non-HTML mail
> clients";
> if(!$mail->Send())
> {
> echo "Message could not be sent. <p>";
> echo "Mailer Error: " . $mail->ErrorInfo;
> exit;
> }
> echo "Message has been sent";
> ?>
> // end of wyslij_zaw.php
>
> // and the last one
>
> //uzytkownik.php
> <html>
> <head>
> <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2" />
> </head>
> <body>
> <?php
> // include('./zawiadomienia.php');
> include('./wyslij_zaw.php')
> ?>
>
> </body></html
> // end of uzytkownik.php
>
>
> it worked great until i added two "for" loops in "zawiadomienie.php"
>
> and now user who sends data gets on the screen only variables from the both
> "for" loops
> and the one who recives is getting email with all the form variables without
> the ones from the "for" loops
>
> I have no idea why it doesn't work properly :((
>
> Thanks for any ideas
> Leszek
>
>
>
>
>
>
Leszek,
I think your problem is in "zawiadomienie.php". In this script, you
first begin to build the variable '$tresc1' then you stop appending to
this variable and echo the contents of your for loop to the client. You
then do the same for the variable '$tresc2'.
Try changing your for loop to continue appending to the proper variables.
//example code for _second_ loop:
$tresc2 .= "<b><p>";
for ($i=1;$i<=5;$i++){
$osoba=$_POST["name"."$i"];
if (strlen($osoba)>0){
$tresc2 .= $osoba."<br>";
}
}
$tresc2 .= "</p></b>";
// end-example.
This should address getting the complete text in the email, though I
think that at this point you will not see any of this on screen. If you
wish to see it on screen, in 'uzytkownik.php' add:
echo $tresc1 .'<br />'. $tresc2;
anytime after including 'zawiadomienia.php'.
Hope this helps.
Carl.
[Back to original message]
|