0

I want to encode an email id in a text box. An email id is saved in database. When page loads i retrieve email id from database using php and display in text input and when i see the email id in page source then the email id should be encoded. How to do this using php and html?

1 Answers1

0

Try this:

function encode_email($e) {
  $output = '';
  for ($i = 0; $i < strlen($e); $i++) { $output .= '&#'.ord($e[$i]).';'; }
  return $output;
}

 echo(encode_email('email@in.com'));
Engineer
  • 5,911
  • 4
  • 31
  • 58
  • It throws a notice as `$output` is not initiated before. – insertusernamehere Feb 27 '13 at 14:06
  • Thanks for your reply . I have tried with the same encoding method only. But in page source the text input is displaying as and in UI text input its displaying as ss@dd.com and not displaying actual email-id in UI text input. How to solve this problem? – Sandeep Prabhu Feb 28 '13 at 04:03