 |
|
10-05-2007, 02:22 PM
|
|
#1
|
 |
|
Adept (Level 5)
Join Date: Jan 2007
Posts: 41
|
stripslashes for textarea
Hey,
How can I remove slashes that appear after an apostrophe in a textarea that I'm sending as an email?
This is the code for the form:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
Name : Extended
Description: A two-column, fixed-width, Web 2.0 design.
Version : 1.0
Released : 20070915
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Trinity Youth Group</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="../../default.css" rel="stylesheet" type="text/css" media="screen" />
<!--[if IE]>
<style type="text/css">
#menu a {
position:relative;
}
</style>
<![endif]-->
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
<h1>Trinity Lutheran Church</h1>
<h2>Youth Group</h2>
<p>Milford, CT</p>
</div>
<div id="search">
<form method="get" action="">
<fieldset>
<input id="s" type="text" name="s" value="" />
<input id="x" type="submit" value="Search" />
</fieldset>
</form>
</div>
</div>
<!-- end header -->
<!-- start menu -->
<div id="menu">
<ul>
<li><a href="../../index.php">Home</a></li>
<li><a href="../../about.php">About</a></li>
<li><a href="../../events.php">Upcoming Events</a></li>
<li><a href="../../calendar.php">Calendar</a></li>
<li><a href="../../contact.php">Contact Us</a></li>
</ul>
</div>
<div id="menu2">
<ul>
<li class="current_page_item"><a href="../index.php">Admin Panel</a></li>
</ul>
</div>
<!-- end menu -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<h1 class="pagetitle">Mass Email</h1>
<div class="post">
<?php
// Make a MySQL Connection
mysql_connect("mysql.****.***", "****", "****") or die(mysql_error());
mysql_select_db("****") or die(mysql_error());
// Get all the data from the "example" table
echo "<form action=\"massemailsend.php\" method=\"get\">";
$result = mysql_query("SELECT email from
contacts; ")
or die(mysql_error());
echo "<b>Note:</b> Try to NOT use apostrophes. They will appear with a backslash next to them because of the coding. I'll let you know when this is fixed.<br><br>";
echo "To:<br>";
echo "<textarea hidden=true name=\"emailfield\" cols=\"50\" rows=\"5\">";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
if ($row['email'] != ''){
echo $row['email'];
echo ", ";
}
}
echo "</textarea>";
echo "<br><br>Subject:<br>";
echo "<input name=\"emailsubject\" type=\"text\">";
echo "<br><br>Message:<br>";
echo "<textarea name=\"emailmessage\" cols=\"50\" rows=\"10\"></textarea>";
echo "<br><br>Signature:<br>";
echo "<textarea name=\"emailsignature\" cols=\"50\" rows=\"3\">- Trinity Lutheran Church Youth Group</textarea>";
echo "<br><br><input name=\"Submit\" type=\"submit\" value=\"Send\">";
echo "</form>";
?>
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li>
<h2>Event Sign Up</h2>
<?php include("../../eventsidebar.php"); ?>
</li>
<li>
<h2>Calendar</h2>
<?php include("../../calendarsidebar.php"); ?>
</li>
</ul>
</div>
<!-- end sidebar -->
<div style="clear: both;"> </div>
</div>
<!-- end page -->
<div id="footer">
<p>©2007 All Rights Reserved. • Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a> • Icons by <a href="http://www.famfamfam.com/">FAMFAMFAM</a>.</p>
</div>
</body>
</html>
Any thoughts?
Thanks!
|
|
Add to del.icio.us
Can you digg it?
|
|
|
10-05-2007, 04:03 PM
|
|
#4
|
 |
|
Deity (Level 17)
Join Date: Dec 2005
Location: Compton
Posts: 916
|
I'm not really sure what you mean. How is it different than any other element?
Can't you just do this?
echo stripslashes($row['email']);
instead of this?
echo $row['email'];
|
|
Add to del.icio.us
Can you digg it?
|
|
|
10-07-2007, 09:15 AM
|
|
#5
|
 |
|
Adept (Level 5)
Join Date: Jan 2007
Posts: 41
|
For the textarea where I type the message. I don't know how to apply stipslashes to the line
Code:
echo "<textarea name=\"emailmessage\" cols=\"50\" rows=\"10\"></textarea>";
Last edited by pwydra : 10-07-2007 at 09:17 AM.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
10-07-2007, 11:08 AM
|
|
#6
|
 |
|
Deity (Level 17)
Join Date: Dec 2005
Location: Compton
Posts: 916
|
You're being really unclear.
What is the problem? That the e-mail is coming through with slashes in it? Or that the textarea itself contains slashes when editing content?
If slashes are coming through in the e-mail, you need to just use stripslashes() on the content of the e-mail before you send it.
But again, I don't see what the difference is between a textarea or any other form element in that case.
If you can, please explain better what is going on.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
10-07-2007, 11:47 AM
|
|
#7
|
 |
|
Adept (Level 5)
Join Date: Jan 2007
Posts: 41
|
ok, sorry. The email when it comes contains slashes after apostrophes that were typed in the "message" text box from the page.
For instance:
would appear as
in the email
My question is how do I apply the stripslashes to anything that is typed into the text box so that won't happen?
Thanks.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
10-07-2007, 12:46 PM
|
|
#8
|
 |
|
Deity (Level 17)
Join Date: Dec 2005
Location: Compton
Posts: 916
|
Right.. so when you put your content into the PHP mail() function or hopefully a different, more secure mail function, you need to put stripslashes() on the content of the email.
This would be something that happens in your form processing script.
Where is massemailsend.php?
|
|
Add to del.icio.us
Can you digg it?
|
|
|
10-07-2007, 01:42 PM
|
|
#9
|
 |
|
Adept (Level 5)
Join Date: Jan 2007
Posts: 41
|
In the same directory.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
Name : Extended
Description: A two-column, fixed-width, Web 2.0 design.
Version : 1.0
Released : 20070915
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Trinity Youth Group</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="REFRESH" content="1;url=http://www.trinityyouthmilford.org/admin/index.php">
<link href="../../default.css" rel="stylesheet" type="text/css" media="screen" />
<!--[if IE]>
<style type="text/css">
#menu a {
position:relative;
}
</style>
<![endif]-->
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
<h1>Trinity Lutheran Church</h1>
<h2>Youth Group</h2>
<p>Milford, CT</p>
</div>
<div id="search">
<form method="get" action="">
<fieldset>
<input id="s" type="text" name="s" value="" />
<input id="x" type="submit" value="Search" />
</fieldset>
</form>
</div>
</div>
<!-- end header -->
<!-- start menu -->
<div id="menu">
<ul>
<li><a href="../../index.php">Home</a></li>
<li><a href="../../about.php">About</a></li>
<li><a href="../../events.php">Upcoming Events</a></li>
<li><a href="../../calendar.php">Calendar</a></li>
<li><a href="../../contact.php">Contact Us</a></li>
</ul>
</div>
<div id="menu2">
<ul>
<li class="current_page_item"><a href="../index.php">Admin Panel</a></li>
</ul>
</div>
<!-- end menu -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<h1 class="pagetitle">Mass Email</h1>
<div class="post">
<?php
echo "<i>To: $emailfield <br><br>Subject: $emailsubject <br><br>Message: <br>$messagescript</i>";
echo "<br><br><br><strong>Email Sent!</strong><br><br><strong>You are now being redirected</strong>";
$toscript = "$emailfield";
$subjectscript = "$emailsubject" ;
$messagescript = "$emailmessage \n \n $emailsignature";
$fromscript = "From: directors@trinityyouthmilford.org";
if ($toscript != "")
mail($toscript, $subjectscript, $messagescript, $fromscript);
?>
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li>
<h2>Event Sign Up</h2>
<?php include("../../eventsidebar.php"); ?>
</li>
<li>
<h2>Calendar</h2>
<?php include("../../calendarsidebar.php"); ?>
</li>
</ul>
</div>
<!-- end sidebar -->
<div style="clear: both;"> </div>
</div>
<!-- end page -->
<div id="footer">
<p>©2007 All Rights Reserved. • Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a> • Icons by <a href="http://www.famfamfam.com/">FAMFAMFAM</a>.</p>
</div>
</body>
</html>
|
|
Add to del.icio.us
Can you digg it?
|
|
|
10-07-2007, 03:10 PM
|
|
#10
|
 |
|
Lord (Level 16)
Join Date: Feb 2006
Location: Houston, Texas
Posts: 719
|
PHP Code:
mail($toscript, $subjectscript, stripslashes($messagescript), $fromscript);

__________________
-Billy
"Traditional software is like witchcraft. In history, witchcraft just died out. The same will happen in software. When problems get serious enough, you can't have one person or one company guarding their secrets. You have to have everybody share in knowledge." --- Linus Torvalds
I am using Linux every day to up my productivity - so up yours!
|
|
Add to del.icio.us
Can you digg it?
|
|
|
10-07-2007, 04:14 PM
|
|
#11
|
 |
|
Hero (Level 10)
Join Date: Jun 2007
Posts: 92
|
Quote:
Originally Posted by pwydra
For the textarea where I type the message. I don't know how to apply stipslashes to the line
Code:
echo "<textarea name=\"emailmessage\" cols=\"50\" rows=\"10\"></textarea>";
|
There's the confusion - you don't apply the function to the textarea line. As @Billy showed, you apply the function to the textarea object itself.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
KEEP TABS |
|
SPONSORS |
| |

|
| |
|
|
| |
|