WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How-to put a contact form on the main index? (3 posts)

  1. isaidicanshout
    Member
    Posted 5 years ago #

    http://isaidicanshout.com/isics/

    so here's what i'm working on so far, everything built from the ground up. ignore the content entries, they are placeholders.

    down in the contact area (bottom right, yellow stripe) is a contact form i built in php from a tutorial. it doesn't seem to work properly. it's supposed to require the fields provided and send an email, pretty basic.

    if you submit the form without filling ANYTHING out, it reloads the page with warning type about the missing fields but the form is gone.

    if you submit a complete or partially complete form you get a post not found page.

    i still have not sent myself a real email.

    here's the code i am using. i am open to starting from scratch or using a plugin, but i have not found a plugin that works from index.php:

    <?php
    
    if(isset($_POST['submit_1'])) {
    
    $name = $_POST['name'];
    $contact = "TEST@TEST.TEST";
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $error = "";
    $headers = 'From:'.' '. $email;
    
    if($name=="") $error.="Please enter a name"."";
    if($email=="") $error.="Please enter your e-mail"."";
    if($subject=="") $error.="Please enter a subject"."";
    if($message=="") $error.="Please enter a message"."";
    if($error==""){
        echo "<div class='error'>". "Thanks for your message!" ."</div>";
    }
    else {
        echo "<div class='error'>". $error ."</div>";
    }
    
    }
    
    else
    {
    ?>
    	<h2>&nbsp;</h2>
    	<h2>SEND ME A MESSAGE</h2>
    
    	<h2>&nbsp;</h2>
    	<h4>FOR WORK-RELATED INQUIRIES, OFFERS OF TECHNOLOGY OR STEAK, OR JUST TO SAY HI.</h4>
    
    	<h2>&nbsp;</h2>
    	<form action="" method="post">
    	<table class="contactform">
    	<tr><td><h2><input type="text" style="width: 160px" name="name" value=""/> YOUR NAME</h2></td></tr>
    	<tr><td><h2><input type="text" style="width: 160px" name="email" value=""/> YOUR E-MAIL</h2></td></tr>
    	<tr><td><h2><input type="text" style="width: 160px" name="subject" value=""/> SUBJECT</h2></td></tr>
    	<tr><td><textarea name="message" style="width: 256px; height:160px;" rows="" cols=""></textarea></td></tr>
    	<tr><td><input type="image" src="http://isaidicanshout.com/isics/images/isics_send.gif" value="submit" name="submit_1" /></td></tr>
    	</table>
    	</form>
    <?php
    }
    ?>
  2. esmi
    Forum Moderator
    Posted 5 years ago #

  3. isaidicanshout
    Member
    Posted 5 years ago #

    that one still didn't want to play nicely in my index page, and i wasnt able to remove the phone number, are you human, or cc box without breaking it, nor was i able to change the subject selector without breaking it.

    i ended up going with an external php file. there's a visible redirect, but it's smooth enough, and i did it myself, which feels good.

    would be nice to do it without a redirect, but i'm not sure it's possible.

Topic Closed

This topic has been closed to new replies.

About this Topic