Title: Call PHP variable in CF7
Last modified: March 12, 2018

---

# Call PHP variable in CF7

 *  [Sanjay](https://wordpress.org/support/users/rsclmumbai/)
 * (@rsclmumbai)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/call-php-variable-in-cf7/)
 * Hi,
 * I’ve stumbled upon a rather unique issue.
 * In my theme’s header.php, I have the following code.
    `$ConvCheckboxRandomNo 
   = rand(10000,90000);`
 * I need to call this variable in my contact form.
    Something like this: <input
   type=”hidden” name=”MyName” value=”$ConvCheckboxRandomNo”> AND in Javascript 
   <script>alert(‘$ConvCheckboxRandomNo’);</script>”;
 * Can you tell me how this can be done. I tried adding it simply and expectedly
   it did not work. What is the correct way to do this?
 * Thanks!

The topic ‘Call PHP variable in CF7’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [Sanjay](https://wordpress.org/support/users/rsclmumbai/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/call-php-variable-in-cf7/)
 * Status: not resolved