+ Reply to Thread
Results 1 to 4 of 4

Thread: how do i make a contact form

  1. #1
    coolv1994 is offline x10 Elder coolv1994 is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    506

    Lightbulb how do i make a contact form

    ive tried diffrent codes but none of them workso will someone give me a working code for a contact form

  2. #2
    Chris73's Avatar
    Chris73 is offline x10 Spammer Chris73 is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    New York
    Posts
    5,360

    Re: how do i make a contact form

    You need to make 2 files. One for the "PHP" and one for the "Java Script"

    Code:
    <?php
    /*
    
    
    
    
    This script is a basic contact form which uses AJAX to pass the information to php, thus making the page appear to work without any refreshing or page loading time.
    
    */
    
    $to = "EMAIL HERE"; //This is the email address you want to send the email to
    $subject_prefix = "User Name here"; //Use this if you want to have a prefix before the subject
    
    if(!isset($_GET['action']))
    {
    die("You must not access this page directly!"); //Just to stop people from visiting contact.php normally
    }
    
    /* Now lets trim up the input before sending it */
    
    $name = trim($_GET['name']); //The senders name
    $email = trim($_GET['email']); //The senders email address
    $subject = trim($_GET['subject']); //The senders subject
    $message = trim($_GET['msg']); //The senders message
    
    mail($to,$subject,$message,"From: ".$email.""); //a very simple send
    
    echo 'contactarea|Thank you '.$name.', your email has been sent.'; //now lets update the "contactarea" div on the contact.html page. The contactarea| tell's the javascript which div to update.
    ?>
    The java script portion
    Code:
    function createRequestObject() {
        var ro;
        var browser = navigator.appName;
        if(browser == "Microsoft Internet Explorer"){
            ro = new ActiveXObject("Microsoft.XMLHTTP");
        }else{
            ro = new XMLHttpRequest();
        }
        return ro;
    }
    
    var http = createRequestObject();
    
    function sendemail() {
    	var msg = document.contactform.msg.value;
    	var name = document.contactform.name.value;
    	var email = document.contactform.email.value;
    	var subject = document.contactform.subject.value;
    	document.contactform.send.disabled=true; 
    	document.contactform.send.value='Sending....';
    
        http.open('get', 'contact/contact.php?msg='+msg+'&name='+name+'&subject='+subject+'&email='+email+'&action=send');
        http.onreadystatechange = handleResponse;
        http.send(null);
    }
    
    function handleResponse() {
        if(http.readyState == 4){
            var response = http.responseText;
            var update = new Array();
    
            if(response.indexOf('|' != -1)) {
                update = response.split('|');
                document.getElementById(update[0]).innerHTML = update[1];
             
            }
        }
    }
    Last edited by Chris73; 12-10-2007 at 08:14 PM.

  3. #3
    adrenlinerush's Avatar
    adrenlinerush is offline x10 Lieutenant adrenlinerush is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Monmouth, IL
    Posts
    379

    Re: how do i make a contact form

    write your own... you can make the form in html and write a cgi script to recieve the post... you can do it in perl, php, python, ruby and several others... and its not difficult... i'm sure if you google you can find plenty pre-made...
    Austin Mount
    AAS, A+, Compaq/HP APS
    austin@adrenlinerush.net

  4. #4
    coolv1994 is offline x10 Elder coolv1994 is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    506

    Re: how do i make a contact form

    thx 4 the code

+ Reply to Thread

Similar Threads

  1. [PHP] How to create a simple contact form
    By nightscream in forum Tutorials
    Replies: 6
    Last Post: 01-23-2011, 11:37 AM
  2. Need a contact form
    By plaic in forum Off Topic
    Replies: 4
    Last Post: 07-21-2007, 07:44 AM
  3. Some help on coding for a contact form
    By ZeptOr in forum Scripts & 3rd Party Apps
    Replies: 5
    Last Post: 12-31-2006, 12:35 AM
  4. Contact Form v2
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 10-06-2005, 08:08 AM
  5. Contact Form
    By o0slowpaul0o in forum Tutorials
    Replies: 6
    Last Post: 06-11-2005, 04:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers