开发者

Browsers changing <input> value!

开发者 https://www.devze.com 2023-02-11 00:27 出处:网络
So, I have a very simple form: <form action=\"AJAXemail.php\" id=\'email_form\' method=\"POST\" target=\"_blank\" enctype=\"application/x-www-form-urlencoded\">

So, I have a very simple form:

<form action="AJAXemail.php" id='email_form' method="POST" target="_blank" enctype="application/x-www-form-urlencoded"> 
<p> 
<label for="email_from">From:</label> 
<input type="text" id="email_from" name="From" size="42" value=
"User Name<user@example.com>" /><br /> 
<label for="email_body">Message Body</label><br /> 
<textarea id="email_body" name="Body" rows="10" style="width: 100%"></textarea> 
<input type="button" value="Submit" onClick="$('email_form').submit(); bringForth(email_div,false);"/> 
</form>

It does what it is supposed to do, submits the body of the text is e-mailed to me. The problem is who it comes from. All I get is "User Name" Then entire "<user@example.com>" is being stripped off. Therefore, I am unable to reply. Using print_r($_REQUEST) shows that the browser is stripping this off before posting.

I'm sure there is a simple reason for this, as well as a simple solution, but for the life of me I can't find it. I've tried changing the enctype but to no avail.

Thanks in advance, Da开发者_如何学Gove


Try escaping your < and > symbols - "User Name &lt; user@example.com &gt;


Try escaping the angled brackets surrounding the email address: %lt;user@examples.com%gt;


<user@example.com> is considered to be a tag. Try using htmlspecialchars() and htmlspecialchars_decode() on server side


Thanks for the help everyone, but as it turns out these aren't the issue. The $header string needed a space between the "From:" and the POSTed string. So, perhaps this was really an Apple Mail bug all along. I created a fixed header string, and it worked like a charm, and the only difference was that space.

--Dave

0

精彩评论

暂无评论...
验证码 换一张
取 消