Log in

View Full Version : Newbie needs help with template please



paul-uk
05-02-2011, 04:20 PM
Hi

I just downloaded a css template which I want to have a play around with.

http://www.templatemo.com/templates/templatemo_283_tomato/

On the contact page, there is a Contact Form.

However, I can't find where to enter my email details to receive the form contents. Ive searched all the css and js pages for "email" or "@" and cannot find anything relevant.

Would anyone know where I could start please.

BTW the template does look fantastic, so thanks to everyone out there who is contributing their work for the benefit of us all.

Paul

Added: I noticed that in IE8 the "contact" text at top right keeps dropping. I can't see anything wrong in the code and it looks fine in FF and Chrome - any ideas on that too?

.

paul-uk
05-02-2011, 05:09 PM
Ive managed to dig out the source code for the Contact Form;


<div class="panel" id="contactus">
<div class="col_w540">
<div id="contact_form">
<h4>Quick Contact</h4>

<form method="post" name="contact" action="#">

<label for="author">Name:</label> <input type="text" id="author" name="author" class="required input_field" />
<div class="cleaner_h10"></div>
<label for="email">Email:</label> <input type="text" id="email" name="email" class="validate-email required input_field" />
<div class="cleaner_h10"></div>

<label for="url">Phone:</label> <input type="text" name="url" id="url" class="input_field" />
<div class="cleaner_h10"></div>

<label for="text">Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required"></textarea>
<div class="cleaner_h10"></div>

<input type="submit" class="submit_button float_l" name="submit" id="submit" value="Send" />
<input type="reset" class="submit_button float_r" name="reset" id="reset" value="Reset" />
</form>

</div>
</div>


What I dont seem to have (can't find) is any type of php coding to get the thing working - Im guessing that would go into
action="#".

Anyone able to show me what php code I would use please?

I could also really do with being able to add in the form;

"reason for contact" and a drop down choice of "a" "b" or "c".

Any ideas please?

Thanks

Beverleyh
05-03-2011, 08:39 AM
There are lots of tutorials online - here's one to get you started: http://www.kirupa.com/web/php_contact_form.htm

You can also Google "contact form tutorial" for more.

deathbycheese
05-03-2011, 08:58 PM
Hi paul-uk,

Try putting this into a separate .php doc and pointing to it in your action="#"




<?php
if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "you@yourdomain.com";
$email_subject = "Your email subject line";


function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}

// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}

$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required

$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

<?php
}
?>


cheers,
dbc

deathbycheese
05-03-2011, 09:03 PM
Oh, and try this to add dropdown selections within your form:



<select name="dropdownTitle">
<option value="" selected>Select One</option>
<option value="choice1">Choice 1</option>
<option value="choice2">Choice 2</option>
<option value="choice3">Choice 3</option>
<option value="choice4">Choice 4</option>
</select>


dbc

Beverleyh
05-04-2011, 07:52 AM
Here's the direct link to the website that provided the code posted by deathbycheese: http://www.freecontactform.com/email_form.php

The additional information in their tutorial may help fill in any gaps.

deathbycheese - Please can you try to post links to the origin of the code if you are reposting from other websites as it avoids quibbles from other webmasters and helps everyone here feel safer about providing code to help others :)
I'm sure you can appreciate that it can be very disheartening to see your own work popup on other websites without any indication of where its come from and its only fair when somebody else has but in the time and effort creating the resource.

deathbycheese
05-04-2011, 02:12 PM
@Beverleyh.
I did NOT get the code from the location you indicate. Please do not assume.
It was a small part of a package I got from simplemodal (http://www.ericmmartin.com/projects/simplemodal/). I do not claim to have written the code myself and am not interested in exploiting others' endeavors.
Thanks.
dbc

djr33
05-04-2011, 03:24 PM
Regardless Beverley is right: posting a link to the source helps for two reasons: 1. it deals with any possible copyright issues, and 2. it helps us to see if there is any documentation etc. Please remember that while we are familiar with the languages and general web design techniques involved, we often have never even heard of a certain script before, so in order to help at all with it, having a link to any sites with more information about it is helpful.
Both your link and hers are helpful. Do the tutorials in the link to the (original?) source answer your questions?

Beverleyh
05-04-2011, 05:03 PM
Sorry for the confusion - I recognised the code for a tutorial I myself had followed in the past and thought it would be helpful to provide the link. I'm glad you clarified the origin of your code deathbycheese and hope you can contribute more to the forums in future.

Best wishes

deathbycheese
05-05-2011, 05:09 PM
Thanks for the kind words, Beverleyh. i will be clearer with my posts/sources.