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
132 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

752 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