Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Wordpress form error 500

Hey,

I building a wordpress site and I have gotten to the Contact form. The form works fine when not using Wordpress but wordpress seems to have an issue, coming up with the http error 500

  <form action="<?php bloginfo("template_url"); ?>/thanks_other.php" method="post">

    <label name="name" for="name">Name</label>
    <input type="text" name="name" id="name_call"/>
    <div class="spacer"></div>
    <label name="email" for="email">Email</label>
    <input type="text" name="email" id="email_call"/>
    <div class="spacer"></div>
    <label name="phone" for="phone">Phone</label>
    <input type="text" name="phone" id="phone_call"/>
    <div class="spacer"></div>
    <input type="submit" name="send" value="SEND" id="submit_call"/>

  </form>

this is the contact form. As I said Wordpress does not find the thanks_other.php page I have also used wp-content/themes/site_name/thanks_other.php in change of just thanks_other.php.

It changes the URL to to the action but can not find the thanks_other.php.

Does anyone know why this is not working.

1 Answer

Nathan Ward
Nathan Ward
7,907 Points

HI,

It seems at the form action you are using double quotation marks to wrap the php in but also using them within the tag, if you replace the quotation marks in the PHP to single quotation marks this should solve your issue.

<form action="<?php bloginfo('template_url'); ?>/thanks_other.php" method="post">
    <label name="name" for="name">Name</label>
    <input type="text" name="name" id="name_call"/>
    <div class="spacer"></div>
    <label name="email" for="email">Email</label>
    <input type="text" name="email" id="email_call"/>
    <div class="spacer"></div>
    <label name="phone" for="phone">Phone</label>
    <input type="text" name="phone" id="phone_call"/>
    <div class="spacer"></div>
    <input type="submit" name="send" value="SEND" id="submit_call"/>
  </form>

I would also suggest making thanks_other.php a page template and then setting up a full page for it within wordpress and then you could redirect the user using the following:

<form action="<?php echo site_url('thanks_other');?>" method="post">
    <label name="name" for="name">Name</label>
    <input type="text" name="name" id="name_call"/>
    <div class="spacer"></div>
    <label name="email" for="email">Email</label>
    <input type="text" name="email" id="email_call"/>
    <div class="spacer"></div>
    <label name="phone" for="phone">Phone</label>
    <input type="text" name="phone" id="phone_call"/>
    <div class="spacer"></div>
    <input type="submit" name="send" value="SEND" id="submit_call"/>
  </form>