Solved

Why is the underscore dropped from an email address entered by a user into a web form when it sends the reply?

Posted on 2014-10-23
5
121 Views
Last Modified: 2014-11-20
We have web forms that are processed by php on several sites. It now appears that any email address entered by a user that contains an underscore is delivered in the reply to the form owner without the underscore. So "somebody_somewhere@yahoo.com becomes somebodysomewhere@yahoo.com when the reply is received from the site.
0
Comment
Question by:weknowjack
5 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40400610
Don't know - maybe because your code is removing it...
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 40400832
This simple test page shows that PHP doesn't do anything with the underscore character.  However, it is still a 'special' character in some situations.  If you submit a variable name with a '.' or a space in it, they will be replaced with an underscore in PHP.
<?php 
error_reporting(E_ALL);
if (!isset($_POST["Email"]))  $Email = '-'; else $Email = substr($_POST["Email"],0,64);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>PHP Underscore Test</title>
</head>
<body>

<h1>PHP Underscore Test</h1>
<p>Previous results: <?php echo $Email; ?></p>
<form action="#" method="post">
<input type="text" name="Email" value="somebody_somewhere@yahoo.com" size="48" />
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>

Open in new window

http://php.net/manual/en/language.variables.external.php
0
 
LVL 30

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 40401101
Have you have a regex  to validate email addresses? Can someone have changes it to improve it? In this case he/she could have inserted a code which produces the problem...
0
 

Author Comment

by:weknowjack
ID: 40402737
Since I posted the question, I heard back from the developer who apparently had coded the script or copied it from some other source containing the anti-spam statements, and he replaced this:

$_POST[$key] = preg_replace("/[^\da-zA-Z@. ]/","",$_POST[$key]);
		if($key != 'antiSpam' && $key != 'Send'){
			$messagecontent .= "<td><b>$key:</b></td><td>$_POST[$key]</td>"; 
		}

Open in new window


with this:

if($key != 'Email'){
			$_POST[$key] = preg_replace("/[^\da-zA-Z@. ]/","",$_POST[$key]);
		}
		if($key != 'antiSpam' && $key != 'Send'){
			$messagecontent .= "<td><b>$key:</b></td><td>$_POST[$key]</td>"; 
		}

Open in new window


It now works. Thanks for your help and time.
0
 
LVL 30

Expert Comment

by:Marco Gasi
ID: 40403627
Hi. Isn't that what I said in my comment?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now