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
129 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 58

Expert Comment

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

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 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 31

Expert Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Woocommerce Webservice 2 106
centralized repository for hosting the internal data and view 1 85
Sharepoint to FTP? 3 79
Places to advertise 6 61
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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 custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

761 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