• Okay so I got an issue, I was trying to figure out how to set up custom pages in wordpress (like a contactform.php kinda deal) I still can’t, I don’t even know where I should upload contactform.php. But say I do sitename.com/contactform.php ill get this error: Fatal error: Call to undefined function get_header() in /home/sitename/public_html/contactme.php on line 1 and this is my code `
    <?php get_header(); ?>
    <?php get_sidebar(); ?>

    <form method=”post” action=”contact.php”>
    Name: <input name=”name” type=”text”>
    Email: <input name=”email” type=”text”>
    Message:
    <textarea name=”message” rows=”15″ cols=”40″></textarea>
    <input type=”submit”>
    </form>

    <?php
    $to = “my@email.com”;
    $subject = “Contact Us”;
    $name = $_REQUEST[‘name’] ;
    $email = $_REQUEST[’email’] ;
    $message = $_REQUEST[‘message’] ;
    $headers = “From: $email”;
    $sent = mail($to, $name, $subject, $message, $headers) ;
    if($sent)
    {print “Your mail was sent successfully!}
    else
    {print “We encountered an error sending your mail”; }
    ?>
    <?php get_footer(); ?>`

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi WebsiteBob,

    There are many plugins where you can create a contact form easily, I use this contact form and it works well, you can even know senders’data for example their ips, browsers, etc.

    Good luck 🙂

    if you are trying to make your php files work, they need to be a template.

    basically, you need to include a header to let WP know that the php file is a page template. Then upload it into your theme…. where your index.php, header.php, etc are

    <?php
    /*
    Template Name: contactForm
    */
    ?>

    goes at the top of the code. Now WP will recognize it as a template. To actually use it on your site, make a page through the WP admin interface (you can leave it blank, just title it Contact Form or something) and select your newly made template from the dropdown template selection menu.

    And if you go the plugin route, google cforms as well…its my fave

    Otherwise, if you do not want to make your php files a template, you have to include WP into your php files. Here’s guidance on that:
    http://codex.wordpress.org/Integrating_WordPress_with_Your_Website
    http://www.corvidworks.com/articles/wordpress-content-on-other-pages

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WordPress disaster!’ is closed to new replies.