Title: custom php values in forms
Last modified: August 19, 2016

---

# custom php values in forms

 *  [cclinton](https://wordpress.org/support/users/cclinton/)
 * (@cclinton)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/custom-php-values-in-forms/)
 * Could use some help with a form I am building for my WordPress theme. Trying 
   to get value that appears when the form loads, hides when the users clicks in
   the field and returns if the user clicks outside the field without adding any
   content. This was pretty easy by using value, onblur and onfocus. Here is where
   things get tricky…
 * When hitting send and generating an error, the form will reload for the user 
   with an error message. I want the form to retain the information they typed into
   the form. Solved that too. However, now the basic value isn’t there and the form
   field is empty until clicked in and clicked out of. Suggestions?
 * Here’s an example:
    <input type=”text” name=”email” id=”email” value=”<?php if(
   isset($_POST[’email’])) echo $_POST[’email’] ;?>” onfocus=”if(this.value==’Your
   Email is’)this.value=”;” onblur=”if(this.value==”)this.value=’Your Email is’;”
   alt=”Your Email” />
 * The trouble I am having is setting up an if/else statement for the value that
   does the following:
    * includes “Your email is” in the field when the form loads*
   auto blanks the field when the user clicks in it * reloads “Your email is” if
   the user clicks outside the field without entering content * retains the information
   they typed in the field if they reload the page or if they submit and the form
   found an error
 * Thanks for reading this over.

The topic ‘custom php values in forms’ is closed to new replies.

## Tags

 * [form](https://wordpress.org/support/topic-tag/form/)
 * [input](https://wordpress.org/support/topic-tag/input/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [value](https://wordpress.org/support/topic-tag/value/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [cclinton](https://wordpress.org/support/users/cclinton/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/custom-php-values-in-forms/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
