Jump to content

Quesstion about wordwrap?


JJohnsenDK

Recommended Posts

hey

I have a quess about the function wordwrap. Im using it in my send mail script but it doesnt seem to work.

Here is the script:

[code]if ($_POST[op] != "send") {
?>
<HTML>
<HEAD>
<TITLE>Send nyhedsbrev</TITLE>
</HEAD>
<BODY>
<h1>Send nyhedsbrev</h1>
<form method="post" action="<? echo $_SERVER['PHP_SELF'] ?>?action=commit_sendmail">
<P><strong>Emne:</strong><br>
<input type="text" name="subject" size=30></p>
<P><strong>Mail tekst:</strong><br>
<textarea name="message" cols=50 rows=10 wrap=virtual></textarea>
<P><strong>Fil:</strong><br>
<input type="file" name="$file"></p>
<input type="hidden" name="op" value="send">
<p><input type="submit" name="submit" value="Send"></p>
</FORM>
</BODY>
</HTML>
<?php
}
}
?>

<?php
function commit_sendmail() {

if ($_POST[op] == "send") {

$file = $_POST['file'];
$subject = $_POST['subject'];
//want to send form, so check for required fields
if ($_POST[subject] =="") {
  echo "Du har ikke skrevet et emne.<br /><br /><a href=".$_SERVER['PHP_SELF']."?action=sendMail>Klik her for at vende tilbage.</a>";
  exit;
  }

if($_POST[message] == "") {
echo "Du har ikke skrevet noget tekst.<br /><br /><a href=".$_SERVER['PHP_SELF']."?action=sendMail>Klik her for at vende tilbage.</a>";
exit;
}

  $subject = wordwrap($subject, 77, "<br />\n");
 
  //connect to database
  $conn = mysql_connect("localhost", "sit00045", "HAjQyLj3")
or die(mysql_error());
  mysql_select_db("sit00045",$conn) or die(mysql_error());

  //get emails from subscribers list
  $sql = "select email from subscribers";
  $result = mysql_query($sql,$conn) or die(mysql_error());

  //create a From: mailheader
  $header = "From: Katrinelund\n";

  //loop through results and send mail
  while ($row = mysql_fetch_array($result)) {
  set_time_limit(0);
  $email = $row['email'];
  mail("$email", stripslashes($_POST[subject]), stripslashes($_POST[message]), $header);
  print "Nyhedsbrev sendt til: $email<br /><br /><a href=".$_SERVER['PHP_SELF']."?action=sendMail>Klik her for at vende tilbage.</a>";
  }
}[/code]

When the mail have been send the wordwrap function should wrap the lines at 77 and put in a <br> but it doesnt, why?
Link to comment
https://forums.phpfreaks.com/topic/28624-quesstion-about-wordwrap/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.