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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
The task of choosing a web design company to build a website for your business should never be taken in a light manner. Provided the fact that your website will act as a representative to your business and will be responsible for imposing an online …
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…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

861 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

23 Experts available now in Live!

Get 1:1 Help Now