0

Using php/html, I want to retrieve email addresses (plus other information) from MySQL and then display the email addresses in an input box on a form. This will enable users to edit and submit corrected email addresses. However the retrieved email address does not display correctly in the input box. All other retrieved information display correctly. A section of the code is as shown below:

 <tr><td ><span style=color:#125eaa><strong>Email</strong></style></td><td ><input style=background-color:#e2ffc6 name=email type=text id=email value=$email></td></tr>
<tr><td ><span style=color:#125eaa><strong> Address Line 1</strong></style></td><td ><input style=background-color:#e2ffc6 name=ad1 type=text id=ad1 value='$ad1'></td></tr> 

The "Address Line 1" displays correctly but the email does not. I tried: type=email, but it did not resolve the issue.

enter image description here

Any help greatly appreciated.

Thanks,

Paul Thomas
  • 281
  • 5
  • 11
  • 2
    You really should add quotes to tag attributes. In addition, you can't simply throw in php variables in HTML. You need to declare them as php. – Scott Feb 05 '12 at 05:07
  • `value='$email'` - with quoting, there? – Borealid Feb 05 '12 at 05:07
  • input element is not closed, and put quotes in attribute values – guido Feb 05 '12 at 05:08
  • Thanks for the feedback. I put the quotes earlier, but it did not work either. Closed the input element, but it also did not work. When I display the email address without using the input box, it works fine. The problem arises when I try to display it in a input form. – Paul Thomas Feb 05 '12 at 05:17

2 Answers2

1

His problem could be an artifact of a resident javascript that's cloaking the e-mail address with a script obfuscation, which is why he's seeing part of the opening script tag. Disable the cloaking script before writing e-mail addresses to values in input statements.

Nick
  • 11
  • 1
1
<tr><td><span style="color:#125eaa;"><strong>Email</strong></span></td><td><input style="background-color:#e2ffc6;" name="email" type="text" id="email" value="<?php echo $email; ?>" /></td></tr>

<tr><td><span style="color:#125eaa;"><strong>Address Line 1</strong></span></td><td><input style="background-color:#e2ffc6;" name="ad1" type="text" id="ad1" value="<?php echo $ad1; ?>" /></td></tr> 

Put quotes around all attributes. And, without seeing more code I can only assume you need to display the variables with php, not simply straight HTML. You've also got closing </style> tags instead of closing </span> tags.

Scott
  • 21,475
  • 8
  • 43
  • 55