Page 1 of 1

stripslahes problem in mailer script

Posted: Mon Jan 26, 2004 9:18 am
by gretchenland.com
I'm relatively new to php and am having trouble with "stripslashes" in a self processing tellafriend mail script I've been working on...
Here's where the form is located>> http://www.gretchenland.com/gforce/tellafriend.htm I'd really appreciate it if someone would take a quick peek at the page and help out with this... The page is an html page with the script innbedded

Posted: Mon Jan 26, 2004 9:24 am
by twigletmac
What is the problem?

Mac

Posted: Mon Jan 26, 2004 10:10 am
by gretchenland.com
The text that's sent asa message with this mailer (text that's input the message text box) shows up with slahes in it if the message contains ' or other special characters...

in example

don't shows up as don''t

Posted: Mon Jan 26, 2004 10:22 am
by JayBird
can we see your code

are you using the [php_man]stripslashes[/php_man]() function?

Mark


edit: fixed link - Sami

Posted: Mon Jan 26, 2004 12:20 pm
by gretchenland.com
Bech100 wrote:can we see your code
are you using the [php_man]stripslashes[/php_man]() function?
I kind a bastardized a few scripts that I found on the net to make this... then when I was testing it -- the slash problem showed up. I then searched for a "cure" and came across "stripslashes" via Google... So far I couldn't find an exampl of it that I could gleen from...

I posted a link to the actual page above because I figured that it would be easier to just look at the page -- here's the form by itself with most of the xtra html removed...

Code: Select all

<html>
<head></head>
<body>
<?php
if (!$Submit){ ?>
      <form action="<?php echo $PHP_SELF; ?>" method="post" name="tafform" id="tafform">
        <TABLE width=400 border=0 cellPadding=5 cellSpacing=0 id="tell-a-friend-form">
          <TBODY>
            <TR> 
              
        <TD align=left class=prompt>Enter Your Name & Email: </TD>
            </TR>
            <TR>
              <TD align=middle class=prompt><TABLE width=329 border=0 align="center" cellpadding="5" cellspacing="0">
                  <TBODY>
                    <TR> 
                      <TD width="135"><div align="right"> Name: </div></TD>
                      <TD width="174"><INPUT name=name class="email_entry_field" size="30" maxLength=50> 
                      </TD>
                    </TR>
                    <TR> 
                      <TD><div align="right"> Email Address:</div></TD>
                      <TD><input name="from_email" type="text" class="email_entry_field" size="30" maxlength="50"> 
                      </TD>
                    </TR>
                    <TR> 
                      <TD colSpan=2></TD>
                    </TR>
                  </TBODY>
                </TABLE></TD>
            </TR>
            <TR> 
              
        <TD align=left class=prompt><BR>
          Enter Your friends' email addresses:<br> <span class="fineprint_NO_BORDER">You 
          may enter as many as you like-- but seperate them with a "," 
          </span></TD>
            </TR>
            <TR align="left"> 
              <TD></TD>
            </TR>
            <TR> 
              <TD align=middle><TABLE width=329 border=0 align="center" cellPadding=0 cellSpacing=0>
            <TBODY>
              <TR> 
                <TD align=center class=prompt><textarea name="to_email" cols="60" rows="3" wrap="VIRTUAL" class="email_entry_field"></textarea></TD>
              </TR>
            </TBODY>
          </TABLE></TD>
            </TR>
            <TR> 
              
        <TD align=left> <input name="subject" type="hidden" id="subject" value="I want you to check out this band!!!">
          Message/Comments: </TD>
            </TR>
            <TR align="center"> 
              <TD height="115"> <textarea name="message" cols="60" rows="8" wrap="VIRTUAL" class="email_entry_field">I just found Gretchen's website and thought that you would  like to check them out!!!</textarea></TD>
            </TR>
            <TR align="center"> 
              <TD><input type="Submit" name="Submit" value="Send!!! "></TD>
            </TR>
          </TBODY>
        </TABLE>


        </form>
<?php
} else {

$headers  = "From: $name <$from_email>\r\n";
$headers .= "Bcc: $to_email\r\n";
 

$line1="This message was sent by $name from Gretchenland.com:";
$line2="Join the Gretchen E-team today & get CD's, shirts, stickers, along with other cool stuff by helping promote Gretchen online!!! For more info go to http://www.gretchenland.com/gforce";
mail("$to","$subject","$line1\n\n\n$message),\n\n$line2\n","$headers");
print "<br><b>Your email has been sent</b><p>";
print "<b>This is what you submitted:</b><p>";
print "<b>Your Name:</b> $name<p>";
print "<b>E-Mail:</b> $from_email<p>";
print "<b>Message/Comments:</b><br>$message<p>";
print "<a href="http://www.gretchenland.com/gforce/tellafriend.htm"> &laquo;&laquo; go back</a></font>";
} ?> 
     
</body>
</html>
This is what I had tried...

Code: Select all

$message = "stripslashes($message)";
it was below

Code: Select all

$headers  = "From: $name <$from_email>\r\n";
$headers .= "Bcc: $to_email\r\n";

Posted: Tue Jan 27, 2004 2:58 am
by twigletmac
You mustn't put function calls into quotes:

Code: Select all

<?php
$message = 'test "this is a test"';

$message = "stripslashes($message)";
echo $message;
?>
literally prints out:
stripslashes(test \"this is a test\")
if, however, you do:

Code: Select all

<?php
$message = 'test "this is a test"';
$message = stripslashes($message);
echo $message;
?>
you get:
test "this is a test"
Mac

Posted: Tue Jan 27, 2004 11:23 am
by gretchenland.com
Thanks you very very much!! --