April 27, 2012
PHP not working correctly in WordPress
Question by Alexander Charles
I have made a plain PHP widget to be displayed on a WordPress sidebar. I have successfully made the widget post the data I am hoping to have filled in on the consecutive page. However where it is supposed to be will not fill in, instead it fills in with "<?php echo $_GET["
then after the text box " />"
. I am hoping that the email first submitted will fill in on the form on the next page. The code that I have for the registration form is part of a greater widget and looks like the following:
<p class="form-email'.$errorVar.'">
<label for="email">'. __('E-mail', 'profilebuilder') .$errorMark.'</label>
<input class="text-input" name="email" type="text" id="email" value="<?php echo $_GET["email"]; ?>" />
</p><!-- .form-email -->';
Here is a link to the page: http://universityoutfitters.com/testphp/ — the widget is on the bottom left hand side panel.
Additional information:
The code for the widget is as follows:
<form action="http://universityoutfitters.com/sign-up/" method="post">
Please submit your email address
Email: <input type="text" name="email" />
<input type="submit" />
</form>
Answer by Starx
As the comments told above, you have to wrap it correctly with PHP tags
<?php
echo '<p class="form-email'.$errorVar.'">
<label for="email">'. __('E-mail', 'profilebuilder') .$errorMark.'</label>
<input class="text-input" name="email" type="text" id="email" value="'.$_GET["email"].'" />
</p><!-- .form-email -->';
?>