Author Topic: How to hide echo "$password" form values?  (Read 1586 times)

Hayssam

  • New Member
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
How to hide echo "$password" form values?
« on: June 28, 2011, 10:16:20 AM »
Ok so I have a form where the username and password inputs are needed to be hidden

PHP Code:
Code: [Select]
<?php 
if($_POST['submit']) 
       { 
$username "Username"
$password "password"
$link     "index.php"


<-- 
More code not relevant to Q --> 

?>


Blah blah blah

<?php  
}  
else  
{  
?>


<form action="<?=$link;?>" method="post">
<input type="hidden" name="username" value="<?=$username;?>" />

<input type="hidden" name="password" value="<?=$password;?>" />

<textarea name="message" cols="10" rows="3"></textarea>

<input type="submit" name="submit" value="Submit" />
</div>

<?php 
  

?>
That is what I currently have but obviously if someone was to view source they would be able to see the info which is a security risk so my Q is

How can I hide the values from source?


Note:PHP newbie so please post code example

As always thank you in advance

Smokey PHP

  • Web Developer
  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 618
  • Karma: 9
    • View Profile
Re: How to hide echo "$password" form values?
« Reply #1 on: June 28, 2011, 01:51:32 PM »
Hi there,

No PHP is viewable from the client. View the source yourself, all you will see is "Blah blah blah". For php code to be viewable it will require the 'echo' or 'print' method.

jSherz

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 409
  • Karma: 4
    • View Profile
    • jSherz.com
Re: How to hide echo "$password" form values?
« Reply #2 on: January 02, 2012, 08:29:13 AM »
Hi there,

No PHP is viewable from the client. View the source yourself, all you will see is "Blah blah blah". For php code to be viewable it will require the 'echo' or 'print' method.

He is outputting the data into the form - so it would be visible.

@Hayssam Unless the remote end (site your sending the form to) accepts an encrypted password, you can't avoid sending it to the user.
Looking for PHP tutorials? View mine. Please use code or PHP tags in your posts.