Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
148 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 84

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 31

Accepted Solution

by:
Marco Gasi earned 2000 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 31

Expert Comment

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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New Relic recently released its Synthetics product that allows for the creation of performance monitors that periodically test a site's performance. If you wish to test an interactive workflow New Relic employs Selenium WebDriverJS to run those test…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Suggested Courses

824 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