title: input type password value?
body: <p>hello i have a problem with the following issue:</p>
  
  <p>i have two input fields. one is for the login username i.e. and the other one is the password. now i would like to set the value of both fields. my problem is the password. my intend to realize that is the following:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input 
  type="text"
  id="log_password" 
  name="log_password" 
  value="&lt;?php echo ($log_password);?&gt;" 
  onfocus="if(this.value=='Password')this.value='';this.type='password'"
  onblur="if(this.value=='') this.value=this.defaultValue;"/&gt;
  </code></pre>
  
  <p>PHP: </p>
  
  <pre><code>$log_password = "Password";
  
  if(isset($_POST['submit'])){
  
      $log_password = $_POST['log_password'];
  
          if(empty($log_password)){
              $errors['log_password'][]="No password given";
              $_POST['log_password'] = "Password";
              $log_password = $_POST['log_password'];
      }       
  }
  </code></pre>
  
  <p>the problem is that this works up to the point where the form will be submitted. in case of an error the password is visible again because of the <code>type="text"</code> tag. so how can i solve this, if there is someone who could help me out i really would appreciate. thanks a lot.</p>
  
  <p>UPDATE:</p>
  
  <pre><code>&lt;div class="small2"&gt; 
  &lt;?php if (!isset($errors['log_password'])):?&gt;
  &lt;input 
  type="&lt;?= $passwordVal == "" ? "text" : "password" ?&gt;" 
  id="log_password" name="log_password" 
  value="&lt;?php echo ($log_password);?&gt;" 
  placeholder="Passwort" 
  onfocus="if(this.value=='Passwort')this.value=''" 
  onblur="if(this.value=='') this.value=this.defaultValue;"/&gt;
  &lt;?php endif;?&gt;
  
  &lt;?php if (isset($errors['log_password'])):?&gt;
  &lt;input class="log-err" 
  type="&lt;?= $passwordVal == "" ? "text" : "password" ?&gt;" 
  id="log_password" name="log_password" 
  value="&lt;?php echo ($log_password);?&gt;" 
  placeholder="Passwort" 
  onfocus="if(this.value=='Passwort')this.value=''" 
  onblur="if(this.value=='') this.value=this.defaultValue;"/&gt;
  &lt;?php endif;?&gt;
  &lt;/div&gt;
  </code></pre>