I need to create a very simple contact form in the homepage with just 3 fields.Is there a way for showing the contact form without a plugin?
I dont want to create a page with a contact form template for that.
thk.
The Agregado Theme comes with a little contact form I modified for one of my themes, I guess it's ok for you to use it as long as the credits remain there.
<?php
//Contact script created by Tim McDaniels and Darren Hoyt for the Mimbo Pro and Agregado themes, modified by Mario Aguiar cuz it didn't work.
//May be re-used with credits intact
if($_REQUEST['submit']):
$admin_email = get_option( "admin_email" );
$admin_subject = 'Inquiry';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $admin_email . "\r\n";
$body = "<blockquote>
Name: " . $_REQUEST['Name'] . "<br/>
Email: " . $_REQUEST['Email'] . "<br/>
Message:<br/>" . $_REQUEST['Message'] . "<br/>
<hr/>
Remote Address: " . $_SERVER['REMOTE_ADDR'] . "<br/>
Browser: " . $_SERVER['HTTP_USER_AGENT'] . "
<hr/>
</blockquote>";
mail ($admin_email, $admin_subject, $body, $headers);
endif; ?>
<form onsubmit="return(submitContactForm(this));" id="contactform" action="">
<h5>Contact</h5>
<fieldset>
<legend>Contact</legend>
<label for="user-name">Name:</label>
<input type="text" id="user-name" name="Name" class="field" title="Enter name here" />
<label for="user-email">Email:</label><br />
<input type="text" id="user-email" name="Email" class="field" title="Enter email address here" />
<label for="user-comment">Message:</label>
<textarea id="user-comment" name="Message" class="field" cols="" rows="4" title="Enter comments here"></textarea>
<input type="hidden" name="submit" value="1" />
<input type="submit" value="" id="homeContactSubmit" class="button" />
</fieldset>
</form>
You'll have to add some captcha to prevent spam, but it works. I have this working on my theme Celeste.
create_a_contact_form()
function in WordPress if that's what you're hoping for ... though WordPress does have many helper functions for different tasks, if you want to ask specifics i'll try to answer.. (example: is there a function that does X?).