Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > PHP Programming
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-05-2007, 02:22 PM
  #1
pwydra
Adept (Level 5)
 
Join Date: Jan 2007
Posts: 41
iTrader: (0)
pwydra is an unknown quantity at this point
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;">&nbsp;</div>
</div>
<!-- end page -->
<div id="footer">
	<p>&copy;2007 All Rights Reserved. &nbsp;&bull;&nbsp; Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a> &nbsp;&bull;&nbsp; Icons by <a href="http://www.famfamfam.com/">FAMFAMFAM</a>.</p>
</div>
</body>
</html>
Any thoughts?

Thanks!
pwydra is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-05-2007, 02:58 PM
  #2
acslater323
Deity (Level 17)
 
acslater323's Avatar
 
Join Date: Dec 2005
Location: Compton
Posts: 916
iTrader: (0)
acslater323 is on a distinguished road
Stripslashes() didn't work?
__________________
Wasn't it a millionaire who said, "Imagine no possessions?" -Elvis Costello
CSS Layouts
CSS Sprites
CSS Menus
My Portfolio
acslater323 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-05-2007, 03:00 PM
  #3
pwydra
Adept (Level 5)
 
Join Date: Jan 2007
Posts: 41
iTrader: (0)
pwydra is an unknown quantity at this point
I don't know how to do it for the textarea.
pwydra is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-05-2007, 04:03 PM
  #4
acslater323
Deity (Level 17)
 
acslater323's Avatar
 
Join Date: Dec 2005
Location: Compton
Posts: 916
iTrader: (0)
acslater323 is on a distinguished road
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'];
__________________
Wasn't it a millionaire who said, "Imagine no possessions?" -Elvis Costello
CSS Layouts
CSS Sprites
CSS Menus
My Portfolio
acslater323 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2007, 09:15 AM
  #5
pwydra
Adept (Level 5)
 
Join Date: Jan 2007
Posts: 41
iTrader: (0)
pwydra is an unknown quantity at this point
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.
pwydra is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2007, 11:08 AM
  #6
acslater323
Deity (Level 17)
 
acslater323's Avatar
 
Join Date: Dec 2005
Location: Compton
Posts: 916
iTrader: (0)
acslater323 is on a distinguished road
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.
__________________
Wasn't it a millionaire who said, "Imagine no possessions?" -Elvis Costello
CSS Layouts
CSS Sprites
CSS Menus
My Portfolio
acslater323 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2007, 11:47 AM
  #7
pwydra
Adept (Level 5)
 
Join Date: Jan 2007
Posts: 41
iTrader: (0)
pwydra is an unknown quantity at this point
ok, sorry. The email when it comes contains slashes after apostrophes that were typed in the "message" text box from the page.

For instance:

Code:
It's a test
would appear as

Code:
It\'s a test
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.
pwydra is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2007, 12:46 PM
  #8
acslater323
Deity (Level 17)
 
acslater323's Avatar
 
Join Date: Dec 2005
Location: Compton
Posts: 916
iTrader: (0)
acslater323 is on a distinguished road
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?
__________________
Wasn't it a millionaire who said, "Imagine no possessions?" -Elvis Costello
CSS Layouts
CSS Sprites
CSS Menus
My Portfolio
acslater323 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2007, 01:42 PM
  #9
pwydra
Adept (Level 5)
 
Join Date: Jan 2007
Posts: 41
iTrader: (0)
pwydra is an unknown quantity at this point
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;">&nbsp;</div>
</div>
<!-- end page -->
<div id="footer">
	<p>&copy;2007 All Rights Reserved. &nbsp;&bull;&nbsp; Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a> &nbsp;&bull;&nbsp; Icons by <a href="http://www.famfamfam.com/">FAMFAMFAM</a>.</p>
</div>
</body>
</html>
pwydra is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2007, 03:10 PM
  #10
BillyGalbreath
Lord (Level 16)
 
BillyGalbreath's Avatar
 
Join Date: Feb 2006
Location: Houston, Texas
Posts: 719
iTrader: (0)
BillyGalbreath is on a distinguished road
PHP Code:
mail($toscript$subjectscriptstripslashes($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!
BillyGalbreath is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2007, 04:14 PM
  #11
rfresh
Hero (Level 10)
 
Join Date: Jun 2007
Posts: 92
iTrader: (0)
rfresh is on a distinguished road
Quote:
Originally Posted by pwydra View Post
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.
__________________
RalphS
Recursive Search/Replace/Preview files on your website.
http://www.FTPWebEdit.info
rfresh is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2007, 04:49 PM
  #12
pwydra
Adept (Level 5)
 
Join Date: Jan 2007
Posts: 41
iTrader: (0)
pwydra is an unknown quantity at this point
Thank you all very much!
pwydra is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Reply
KEEP TABS
SPONSORS
 
Boxedart

 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 05:48 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.