Menu

<br /> instead of NewLine character???

Help
eschamp
2005-12-08
2013-06-03
  • eschamp

    eschamp - 2005-12-08

    I enter the following in a textarea of a fom created with v2.09:

    1 cup butter
    1 onion, chopped very finely
    2 pkgs. frozen chopped spinach

    And the resulting email shows this:

    1 cup butter&nbsp;<br />1 onion, chopped very finely&nbsp;<br />2 pkgs. frozen chopped spinach

    What have I done wrong???

     
    • TNTEverett

      TNTEverett - 2005-12-08

      Send me the path to your form, and send me your process.php file.

       
      • eschamp

        eschamp - 2005-12-08

        http://trentonsoupkitchen.org/phpform/use/Recipe/
        -----------------------------
        <?php
        include("global.inc.php");
        $errors=0;
        $error="The following errors occured while processing your form input.<ul>";
        pt_register('POST','Category');
        pt_register('POST','RecipeName');
        pt_register('POST','YourName');
        pt_register('POST','Ingredients');
        $Ingredients=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Ingredients);pt_register('POST','Directions');
        $Directions=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Directions);if($Category=="" || $RecipeName=="" || $YourName=="" || $Ingredients=="" || $Directions=="" ){
        $errors=1;
        $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
        }
        if($errors==1) echo $error;
        else{
        $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
        $message="Category: ".$Category."
        Recipe Name: ".$RecipeName."
        Your Name: ".$YourName."
        Ingredients: ".$Ingredients."
        Directions: ".$Directions."
        ";
        $message = stripslashes($message);
        mail("pjh@mccc.edu","Recipe Collection Form",$message,"From: phpFormGenerator");
        ?>
        <!-- This is the content of the Thank you page, be careful while changing it -->
        <link href="../../../task.css" rel="stylesheet" type="text/css">

        <h2>Thank you!</h2>

        <span class="style6">If you would like to reserve one or more <br>
        copies of the cookbook, please click here.
        </span><!--
        <table width=50%>
          <tr>
            <td>Category: </td>
            <td> <?php echo $Category; ?> </td>
          </tr>
          <tr>
            <td>Recipe Name: </td>
            <td> <?php echo $RecipeName; ?> </td>
          </tr>
          <tr>
            <td>Your Name: </td>
            <td> <?php echo $YourName; ?> </td>
          </tr>
          <tr>
            <td>Ingredients: </td>
            <td> <?php echo $Ingredients; ?> </td>
          </tr>
          <tr>
            <td>Directions: </td>
            <td> <?php echo $Directions; ?> </td>
          </tr>
        </table>

        -->
        <!-- Do not change anything below this line -->
        <?php
        }
        ?>

         
    • eschamp

      eschamp - 2005-12-08

      Duh!  I see what's causing the "problem". :-)

       
    • TNTEverett

      TNTEverett - 2005-12-08

      This is the problem:
      preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />",

      Do you still need help?

       
      • eschamp

        eschamp - 2005-12-08

        No, I'm good now, thanks.

        Why is that substitution the default for textarea? It doesn't make sense to me.

        Thanks.

         
        • TNTEverett

          TNTEverett - 2005-12-08

          The idea is that in a text area you may have multiple carriage return and line feed characters (\015\012).  The HTML euqivalent is <br>.  It is still incorrectly implemented for your form but that is the explination.

           
          • eschamp

            eschamp - 2005-12-08

            The form produces a text email. Why would it substitute HTML tabs for text?

            Is the incorrect implementation a flaw in phpformgen??

            Thanks.

             
            • TNTEverett

              TNTEverett - 2005-12-09

              Not sure, I'm not the designer.  There are two functions that use the variables.  The email and the thankyou form. 

               
    • Mike 77

      Mike 77 - 2006-01-31

      i think i have kind of the same problem...but without a solution...

      results of a form are sended in this format:

      Vraag: Beste mevrouw, meneer,&nbsp;<br />&nbsp;<br />Wij zijn op zoek naar een geschikte locatie voor een receptie met ongeveer 200 personen, op maandagavond, 13 februari 2006. De locatie zou mysterieus, speciaal, ...
      moeten kunnen ingekleed worden, of al mysterieus zijn door de ligging, de omgeving... Misschien is jullie locatie in Waver ook geschikt, of Cense D'Almez natuurlijk.&nbsp;<br /> &nbsp;<br />We willen de gasten een receptie van ongeveer 2 uur aanbieden, met drank en wat hapjes, er is een speech, en indien mogelijk wordt de groep in kleine groepjes gesplitst voor een speciale activiteit (is er een mogelijkheid om iedereen in cirkels te laten zitten?)&nbsp;<br />&nbsp;<br />Kan u laten weten of die datum nog vrij is, en kan u ons een of enkele voorstellen doen voor de receptie, met prijsindicatie?&nbsp;<br />&nbsp;<br />Alvast hartelijk bedankt.&nbsp;<br />&nbsp;<br />Met vriendelijke groeten, &nbsp;<br />&nbsp;<br />Lieven&nbsp;<br />

      So the breaks are not displayed and i get a lot of unnessary tags. In the mail-message, but also in the datafile with all results.

      Anyone a solution... since i'm a novice to php...help would be welcome...and i'll learn :-) Thx

      Code of process-file is:

      include("global.inc.php");
      $errors=0;
      $error="The following errors occured while processing your form input.<ul>";
      pt_register('POST','Language');
      pt_register('POST','Company');
      pt_register('POST','Title');
      pt_register('POST','Name');
      pt_register('POST','Firstname');
      pt_register('POST','Address');
      pt_register('POST','PC');
      pt_register('POST','City');
      pt_register('POST','Tel');
      pt_register('POST','Fax');
      pt_register('POST','Email');
      pt_register('POST','TypeContact');
      pt_register('POST','Question');
      $Question=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Question);pt_register('POST','Info');
      pt_register('POST','Date');
      pt_register('POST','IP');
      if($Name=="" || $Firstname=="" || $Address=="" || $PC=="" || $City=="" || $Tel=="" || $Email=="" ){
      $errors=1;
      $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
      }
      if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Email)){
      $error.="<li>Invalid email address entered";
      $errors=1;
      }
      $Date = date("l jS of F Y h:i:s A");
      $IP = $HTTP_SERVER_VARS["REMOTE_ADDR"];
      if($errors==1) echo $error;
      else{
      $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
      $message="Language: ".$Language."
      Company: ".$Company."
      Title: ".$Title."
      Name: ".$Name."
      First name: ".$Firstname."
      Address: ".$Address."
      PC: ".$PC."
      City: ".$City."
      Tel: ".$Tel."
      Fax: ".$Fax."
      Email: ".$Email."
      TypeContact: ".$TypeContact."
      Question: ".$Question."
      Info: ".$Info."
      Date: ".$Date."
      IP: ".$IP."
      ";
      $message = stripslashes($message);
      mail("christian@tconcept.net","Contact Form - Cense d'Almez",$message,"From: $Email");
      $link = mysql_connect("xxxxxxxxxxxxx","xxxxxxxx","xxxxxxxx");
      mysql_select_db("xxxxxxxxxx",$link);
      $query="insert into form_contact (Langue,Societe,Titre,Nom,Prenom,Adresse,CP,Localite,Tel,Fax,Email,ChoixContact,Question,Suivi,Date,IP) values ('".$Language."','".$Company."','".$Title."','".$Name."','".$Firstname."','".$Address."','".$PC."','".$City."','".$Tel."','".$Fax."','".$Email."','".$TypeContact."','".$Question."','".$Info."','".$Date."','".$IP."')";
      mysql_query($query);
      $make=fopen("admin/contact.csv","a");
      $to_put="";
      $to_put .= $Language.";".$Company.";".$Title.";".$Name.";".$Firstname.";".$Address.";".$PC.";".$City.";".$Tel.";".$Fax.";".$Email.";".$TypeContact.";".$Question.";".$Info.";".$Date.";".$IP."
      ";
      fwrite($make,$to_put);

      header("Refresh: 0;url=http://www.censedalmez.be/pages/en/form_ok.htm");

       
      • TNTEverett

        TNTEverett - 2006-01-31

        This happens because the message is being prepared for HTML and is only sent as text. 
        You have 2 options: 
        1.)don't prepare for html by removing this line:
        $Comment=preg_replace(&quot;/(\015\012)|(\015)|(\012)/&quot;,&quot;&amp;nbsp;&lt;br /&gt;&quot;, $Comment);

        2.)send as html by adding the following:
        on the line prior to 
        $message = stripslashes($message);

        add this code

        $header = &quot;From: phpFormGenerator\r\n&quot; .
        &quot;Content-Type: text/html; charset=iso-8859-1\r\n&quot; ;

        then change this line

        mail(&quot;chuck@comiclist.com&quot;,&quot;Form Submitted at your website&quot;,$message,&quot;From:
        phpFormGenerator&quot;);

        to this line

        mail(&quot;chuck@comiclist.com&quot;,&quot;Form Submitted at your website&quot;,$message,$header);

        In your case the easiest will be option 1.  This is due to the fact you are saving to MySQL.  If you still want to receive the message in html more of the process file will have to be rearranged. 

         
    • Charles LePage

      Charles LePage - 2006-01-31

      If I send a comment to myself via my form that reads:

      test message
      test message
      test message

      I receive by email as:

      test message&nbsp;<br />test message&nbsp;<br />test message

      The form is at http://www.comiclist.com/feedback.html.

      The process.php is as follows:

      <?php
      include("global.inc.php");
      $errors=0;
      $error="The following errors occured while processing your form input.<ul>";
      pt_register('POST','Name');
      $Name=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Name);pt_register('POST','EmailAddress');
      pt_register('POST','Comment');
      $Comment=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Comment);if($Name=="" || $EmailAddress=="" || $Comment=="" ){
      $errors=1;
      $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
      }
      if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EmailAddress)){
      $error.="<li>Invalid email address entered";
      $errors=1;
      }
      if($errors==1) echo $error;
      else{
      $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
      $message="Name: ".$Name."
      Email Address: ".$EmailAddress."
      Comment: ".$Comment."
      ";
      $message = stripslashes($message);
      mail("chuck@comiclist.com","Form Submitted at your website",$message,"From: phpFormGenerator");
      $make=fopen("admin/data.dat","a");
      $to_put="";
      $to_put .= $Name."|".$EmailAddress."|".$Comment."
      ";
      fwrite($make,$to_put);

      header("Refresh: 0;url=http://www.comiclist.com/thankyou.html");
      ?><?php
      }
      ?>

       
      • TNTEverett

        TNTEverett - 2006-01-31

        This happens because the message is being prepared for HTML and is only sent as text. 
        You have 2 options:
        1.)don't prepare for html by removing this line:
        $Comment=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Comment);

        2.)send as html by adding the following:
        on the line prior to
        $message = stripslashes($message);

        add this code

        $header = "From: phpFormGenerator\r\n" .
               "Content-Type: text/html; charset=iso-8859-1\r\n" ;

        then change this line

        mail("chuck@comiclist.com","Form Submitted at your website",$message,"From:
        phpFormGenerator");

        to this line

        mail("chuck@comiclist.com","Form Submitted at your website",$message,$header);

         
      • TNTEverett

        TNTEverett - 2006-01-31

        This message is identical to the last one.  Since you removed the line that inserts the <b /> into the string it appears you did not update the process.php file on your web site properly. 

         
    • Charles LePage

      Charles LePage - 2006-01-31

      Process.php is now:

      <?php
      include("global.inc.php");
      $errors=0;
      $error="The following errors occured while processing your form input.<ul>";
      pt_register('POST','Name');
      $Name=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Name);pt_register('POST','EmailAddress');
      pt_register('POST','Comment');
      if($Name=="" || $EmailAddress=="" || $Comment=="" ){
      $errors=1;
      $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
      }
      if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EmailAddress)){
      $error.="<li>Invalid email address entered";
      $errors=1;
      }
      if($errors==1) echo $error;
      else{
      $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
      $message="Name: ".$Name."
      Email Address: ".$EmailAddress."
      Comment: ".$Comment."
      ";
      $message = stripslashes($message);
      mail("chuck@comiclist.com","Form Submitted at your website",$message,"From: phpFormGenerator");
      $make=fopen("admin/data.dat","a");
      $to_put="";
      $to_put .= $Name."|".$EmailAddress."|".$Comment."
      ";
      fwrite($make,$to_put);

      header("Refresh: 0;url=http://www.comiclist.com/thankyou.html");
      ?><?php
      }
      ?>

      And this is what I get:

      Name: chuck
      Email Address: clepage@thig.com
      Comment: test message&nbsp;<br />test message&nbsp;<br />test message

      Did I delete the wrong line?

       
    • Charles LePage

      Charles LePage - 2006-01-31

      Well, I saved the changes, I'm not certain how else to update the file.  I will research further.

       
      • TNTEverett

        TNTEverett - 2006-01-31

        I took your latest process.php file and form, set it up on my server.  The results were as follows:

        Name: T EverettEmail Address: tnteveret1@comcast.netComment: test messageTest messagetest message

        I then added some minor formating and this is what I get:

        Name: T Everett
        Email Address: tnteveret1@comcast.net
        Comment:
        test message
        Test message
        test message

        Here is the process.php file I ended up with:

        <?php
        include("global.inc.php");
        $errors=0;
        $error="The following errors occured while processing your form input.<ul>";
        pt_register('POST','Name'); $Name=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $Name);
        pt_register('POST','EmailAddress');
        pt_register('POST','Comment');
        if($Name=="" || $EmailAddress=="" || $Comment=="" ){
        $errors=1;
        $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
        }
        if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EmailAddress)){
        $error.="<li>Invalid email address entered"; $errors=1;
        }
        if($errors==1)
        echo $error;
        else {
        $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
        $message="\nName: ".$Name."\nEmail Address: ".$EmailAddress."\nComment: \n".$Comment."";
        $message = stripslashes($message);
        mail("chuck@comiclist.com","Form Submitted at your website",$message,"From:phpFormGenerator");
        echo "<li>Done";
        ?>
        <?php
        }

        ?>

         
    • Charles LePage

      Charles LePage - 2006-01-31

      I see what the problem is now.  I was changing the wrong process.php.  The one I need to change is located at www.comiclist.com/form/use/Comment/process.php, but when I try to enter the directory, I get:

      Unable to change directory to /home/comlist/public_html/form/use/Comment! You do not seem to have access permissions! (System Error: Permission denied)

      It's been that way since I created the form.

      I've been changing the file at www.comiclist.com/form/forms/process.php, which my form, of course, is not using.

       
      • TNTEverett

        TNTEverett - 2006-01-31

        Try these things:
        1-Try changing directory permissions.
        2-Try removing any .htaccess or .htpassword files.
        3-Copy what you have to your PC, delete the web directories, then recreate and reload the files.
        4-Get your host support person to modify the permissions for you. 

         
    • Charles LePage

      Charles LePage - 2006-02-01

      Thank you all for your help.  Once I got home, I contacted my host, who changed the permissions.  Once they did that, the form would not work at all.

      I made a new form which is working now, without the <br> issue.

       
    • ilterocktive

      ilterocktive - 2006-04-25

      Sorry guys for being a stone head, but what was the problem?
      Should i remove "&nbsp;<br />" with its commas?
      I have the same problem

       
    • ilterocktive

      ilterocktive - 2006-04-25

      Ok, i think i got it...
      Whole code between 2 "pt_register" has to be gone. I think :) Sorry.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.