Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2010
    Posts
    28
    Thanks
    2
    Thanked 0 Times in 0 Posts

    HTML Quote Contact form

    Hello guys,

    I need a HTML Coded contact form where users can fill all their details out to get a quote.
    Does anyone know where I can find a code for this? Or personalize one myself.

    I have tried basic tutorials, but when I'm looking through the code, it doesn't give me an idea on where the email should go.

    Thanks,
    Ryan

  • #2
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Contact Form

    Edit at your own risk...

    Make an error.html page for when someone does not fill out all the required fields.

    Make a thankyou.html page for a successful form submission.

    Here is the PHP code:
    Name this file contact.php
    Hint - edit the mailto, subject, formurl, errorurl, and thankyouurl variables to your specifications

    PHP Code:
    <?php

    $mailto 
    'your@email.com' ;
    $subject "Your Contact Form" ;
    $formurl "http://www.yoursite.com/contact.html" ;
    $errorurl "http://www.yoursite.com/error.html" ;
    $thankyouurl "http://www.yoursite.com/thankyou.html" ;
    $uself 0;
    $use_sendmailfrom 0;
    $use_webmaster_email_for_from 0;
    $use_utf8 1;
    $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" "\n" ;
    $content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' 'Content-Type: text/plain; charset="utf-8"' ;
    if (isset( 
    $use_sendmailfrom ) && $use_sendmailfrom) {

    ini_set'sendmail_from'$mailto );
    }
    $firstname addslashes($_POST['firstname']) ;
    $lastname addslashes($_POST['lastname']) ;
    $city addslashes($_POST['city']) ;
    $state addslashes($_POST['state']) ;
    $phone addslashes($_POST['phone']) ;
    $email addslashes($_POST['email']) ;
    $website addslashes($_POST['website']) ;
    $subject addslashes($_POST['subject']) ;
    $message addslashes($_POST['message']) ;
    $http_referrer getenv"HTTP_REFERER" );

    if (!isset(
    $_POST['email'])) {

    header"Location: $formurl" );

    exit ;
    }

    $valid_email = (preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/im'$email)) ? true false;
    $valid_firstname = (!empty($firstname)) ? true false;
    $valid_lastname = (!empty($lastname)) ? true false;
    $valid_city = (!empty($city)) ? true false;
    $valid_state = (!empty($state)) ? true false;
    $valid_message = (!empty($subject) && !empty($message)) ? true false;

    $fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email $mailto ;

    if (
    get_magic_quotes_gpc()) {
        
    $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
        while (list(
    $key$val) = each($process)) {
            foreach (
    $val as $k => $v) {
                unset(
    $process[$key][$k]);
                if (
    is_array($v)) {
                    
    $process[$key][stripslashes($k)] = $v;
                    
    $process[] = &$process[$key][stripslashes($k)];
                } else {
                    
    $process[$key][stripslashes($k)] = stripslashes($v);
                }
            }
        }
        unset(
    $process);
    }

    $messageproper =

    "This message was sent from:\n" .

    "$http_referrer\n" .

    "------------------------------------------------------------\n" .

    "First Name: $firstname\n" .
    "Last Name: $lastname\n" .
    "City: $city\n" .
    "State: $state\n" .
    "Phone: $phone\n" .
    "Email: $email\n" .
    "Website: $website\n" .
    "Subject: $subject\n" .

    "------------------------- MESSAGE -------------------------\n\n" .

    $message .

    "\n\n------------------------------------------------------------\n" ;

    $headers "From: \"$firstname\" <$fromemail>" $headersep "Reply-To: \"$firstname\" <$email>" $headersep "X-Mailer: chfeedback.php 2.15.0" $headersep 'MIME-Version: 1.0' $headersep $content_type ;

    if (
    $valid_email && $valid_firstname && $valid_lastname && $valid_city && $valid_state && $valid_message) {
    mail$mailto$subject$messageproper$headers );
    }

    else {
    header"Location: $errorurl" );
    exit ;
    }

    header"Location: $thankyouurl" );
    exit ;

    ?>
    Here is the HTML code:
    Hint - name this file contact.html

    Code:
    <div class="contactform">
    <span style="font-size: 9pt; font-family: Verdana; color: #000000;">
    
    <form action="contact.php" method="post">
    <fieldset><legend><span style="font-size: 12px;">&nbsp;CONTACT DETAILS&nbsp;</span></legend>
     <label for="firstname" class="left">First name:</label>
    <font color="#FF0000">*</font><input type="text" name="firstname" id="firstname" class="field" value="" maxlength="35" tabindex="1" /><br /><br />
    <label for="lastname" class="left">Last name:</label>
    <font color="#FF0000">*</font><input type="text" name="lastname" id="lastname" class="field" value="" maxlength="35" tabindex="2" /><br /><br />
    
    <label for="organization" class="left">Organization:</label>
    <font color="#FF0000">&nbsp;&nbsp;</font><input type="text" name="organization" id="organization" class="field" value="" maxlength="45" tabindex="3" /><br /><br />
    <label for="city" class="left">City:</label>
    <font color="#FF0000">*</font><input type="text" name="city" id="city" class="field" value="" maxlength="35" tabindex="4" /><br /><br />
    <label for="state" class="left">State:</label>
    <font color="#FF0000">*</font><input type="text" name="state" id="state" class="field" value="" maxlength="2" tabindex="5" /><br /><br />
    
    <label for="phone" class="left">Phone:</label>
    <font color="#FF0000">&nbsp;&nbsp;</font><input type="text" name="phone" id="phone" class="field" value="" maxlength="10" tabindex="6" /><br /><br />
    <label for="email" class="left">Email:</label>
    <font color="#FF0000">*</font><input type="text" name="email" id="email" class="field" value="" maxlength="50" tabindex="7" /><br /><br />
    <label for="website" class="left">Website:</label>
    <font color="#FF0000">&nbsp;&nbsp;</font><input type="text" name="website" id="website" class="field" value="" maxlength="60" tabindex="8" /><br /><br />
    </fieldset>
    
    <fieldset><legend><span style="font-size: 12px;">&nbsp;MESSAGE DETAILS&nbsp;</span></legend>
    <label for="subject" class="left">Subject:</label>
    <font color="#FF0000">*</font><input type="text" name="subject" id="subject" class="field" value="" maxlength="35" tabindex="9" /><br /><br />
    <label for="message" class="left">Message:</label>
    <font color="#FF0000">&nbsp;&nbsp;</font><textarea name="message" id="message" cols="45" rows="10" maxlength="400" tabindex="10"></textarea><br /><br />
    <input type="submit" name="submit" id="submit" class="button" value="Send Message" tabindex="11" /><br /><br />
    
    </fieldset>
    </form>
    </span>
    </div>
    Here is the CSS code:

    Code:
    .contactform {
    	width:418px;
    	margin:2.0em 0 0 0;
    	padding:10px 10px 0 10px;
    	border:solid 1px rgb(200,200,200);
    	background-color:rgb(240,240,240);
    	margin-left: auto;
    	margin-right: auto;
    }
    .contactform fieldset {
    	padding:20px 0 0 0 !important;
    	padding:0;
    	margin:0 0 20px 0;
    	border:solid 1px rgb(220,220,220);
    }
    .contactform fieldset legend {
    	margin:0 0 0 5px !important;
    	margin:0 0 20px 5px;
    	padding:0 2px 0 2px;
    	color:rgb(80,80,80);
    	font-weight:bold;
    	font-size:130%;
    }
    .contactform label.left {
    	float:left;
    	width:100px;
    	margin:0 0 0 10px;
    	padding:2px;
    	font-size:110%;
    	text-align:left;
    }
    .contactform select.combo {
    	width:175px;
    	padding:2px;
    	border:solid 1px rgb(200,200,200);
    	font-family:verdana,arial,sans-serif;
    	font-size:110%;
    }
    .contactform input.field {
    	width:275px;
    	padding:2px;
    	border:solid 1px rgb(200,200,200);
    	font-family:verdana,arial,sans-serif;
    	font-size:110%;
    }
    .contactform textarea {
    	width:275px;
    	padding:2px;
    	border:solid 1px rgb(200,200,200);
    	font-family:verdana,arial,sans-serif;
    	font-size:110%;
    }
    .contactform input.button {
    	float:right;
    	width:9.0em;
    	margin-right:19px;
    	margin-bottom:12px;
    	padding:1px !important;
    	padding:0;
    	background:rgb(225,225,225);
    	border:solid 1px rgb(150,150,150);
    	text-align:center;
    	font-family:verdana,arial,sans-serif;
    	color:rgb(150,150,150);
    	font-size:110%;
    }
    .contactform input.button:hover {
    	cursor: pointer;
    	border:solid 1px rgb(80,80,80);
    	background:rgb(220,220,220);
    	color:rgb(80,80,80);
    }
    Enjoy!
    Last edited by cpawebmaster; 05-16-2010 at 01:02 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •