Forums

How to make a custom feedback form without using a plugin? (6 posts)

  1. mayoosuf
    Member
    Posted 3 years ago #

    hi guys i have a problem,

    that is I'm struggling when I'm making a custom PHP form for wordpress Template(Because I don't want to use a plug-in)!, basically I'm using AJAX by the trend of
    http://trevordavis.net/blog/tutorial/ajax-forms-with-jquery/

    guys gimme a solution, because i wanna host my blog for new year

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    Not too sure why you wouldn't use a plugin but if learning ajax is the reason then here's a search that might get you started:

    http://www.google.com/search?q=wordpress+using+ajax+jquery+forms

    Good Luck.

  3. MichaelH
    Volunteer
    Posted 3 years ago #

    And if you want to turn your form into a plugin look at this:
    http://ocaoimh.ie/2008/11/01/make-your-wordpress-plugin-talk-ajax/

    Other resource:
    AJAX_in_Plugins

  4. talgalili
    Member
    Posted 3 years ago #

    mmm... another solution is to use google docs (the spreadsheet solution) - to create and embed a feedback form.

  5. nannum
    Member
    Posted 3 years ago #

    mayoosuf have a look at the comment by ianstapleton on this topic http://wordpress.org/support/topic/209747 it worked for me.

  6. mayoosuf
    Member
    Posted 3 years ago #

    Thank you every one, i made it , but i don't think its an ultimate solution, hmm you guys also have a look and give me your feedbacks, because, i want to learn more and more.

    actually i did't do any big changes, only few parts, now im thinking of enhancing the code by using a Switch Case

    http://shums.info/demo/

    the code is i have written in the template page is

    <?php
    /**
    * @package WordPress
    * @subpackage Default_Theme
    */
    /*
    Template Name: contact form
    */
    ?>

    <?php get_header(); ?>

    <body id="contactform">
    <div id="container">
    <?php
    if(isset($_POST['submitted'])) {
    if($_POST['emailTo'] == '') {
    $emailToError = 'You forgot to enter the email address to send to.';
    } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", $_POST['emailTo'])) {
    $emailToError = 'Enter a valid email address to send to.';
    }
    if($_POST['emailFrom'] == '') {
    $emailFromError = 'You forgot to enter the email address to send from.';
    } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", $_POST['emailFrom'])) {
    $emailFromError = 'Enter a valid email address to send from.';
    }

    if($_POST['subject'] == '') {
    $subjectError = 'You forgot to enter the subject.';
    }

    if($_POST['message'] == '') {
    $messageError = 'You forgot to enter the message.';
    }

    if(!isset($emailToError) && !isset($emailFromError) && !isset($subjectError) && !isset($messageError)) {
    include(TEMPLATEPATH.'/sendEmail.php');
    include(TEMPLATEPATH.'/thanks.php');
    }
    }

    ?>
    <form action="<?php echo get_option('siteurl'); ?>/sendemail.php" method="post" id="sendEmail">
    <h1>Send An Email</h1>
    <p class="alert">* All fields are required</p>
    <ol class="forms">

  7. <label for="emailTo">To</label><input type="text" name="emailTo" id="emailTo" value="<?= $_POST['emailTo']; ?>" /><?php if(isset($emailToError)) echo '<span class="error">'.$emailToError.'</span>'; ?>
  8. <label for="emailFrom">From</label><input type="text" name="emailFrom" id="emailFrom" value="<?= $_POST['emailFrom']; ?>" /><?php if(isset($emailFromError)) echo '<span class="error">'.$emailFromError.'</span>'; ?>
  9. <label for="subject">Subject</label><input type="text" name="subject" id="subject" value="<?= $_POST['subject']; ?>" /><?php if(isset($subjectError)) echo '<span class="error">'.$subjectError.'</span>'; ?>
  10. <label for="message">Message</label><textarea name="message" id="message"><?= $_POST['message']; ?></textarea><?php if(isset($messageError)) echo '<span class="error">'.$messageError.'</span>'; ?>
  11. <li class="buttons"><button type="submit" id="submit" value="no">Send Email »</button><input type="hidden" name="submitted" id="submitted" value="true" />

    </form>
    <div class="clearing"></div>
    </div>
    <?php get_footer(); ?>


    please give me your code enhancement teq's

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags