+ Reply to Thread
Results 1 to 2 of 2

Thread: PHP Contact Us Form

  1. #1
    xxll_martin_llxx is offline x10 Elder xxll_martin_llxx is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    716

    PHP Contact Us Form

    Hey,

    I'm just looking for a little help from a tutorial putting everything together as one.

    Tutorial: http://www.finalwebsites.com/tutoria...ntact_form.php

    Code for my site:

    Code:
    <div class="content1-container-1col">
    <div class="content-txtbox-noshade">
     <p>
    Please use the form below to get in touch with me. Please use a suitable subject to describe what you're writing about.
     </p>
     
    </div>
    </div>
    Not quite sure what goes where with regards to the tutorial, anyone shed some light for me please?

    Thanks in advance.

  2. #2
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: PHP Contact Us Form

    This is what I think it means...

    but you would need to find the code for the required files (which isn't obvious)

    PHP Code:
    <?php
    require_once('phpmailer/class.phpmailer.php');
    require_once(
    'xajax/xajax.inc.php');

    $form '<form id="cform">
                <div>
                  <label for="name">Name</label>
                  <input name="name" type="text" id="naam" value="" size="25" />
                </div>
                <div>
                  <label for="email">E-mail</label>
                  <input name="email" type="text" id="email" value="" size="25" />
                </div>
                <div>
                  <label for="msg">Message</label>
                  <textarea name="msg" id="msg" cols="45" rows="5"></textarea>
                </div>
                <div style="border-top:1px solid #CCCCCC;padding-top:5px;">
                  <label for="subbtn" style="text-align:right;"> --&gt; </label>
                  <input type="button" id="subbtn" value="Submit" onclick="xajax_myFunction(xajax.getFormValues(\'cform\'));" />
                </div>
              </form>'
    ;
                
    function 
    myFunction($get) { 
        global 
    $form$error;
        
    $error '';
        
    $objResponse = new xajaxResponse();
        
    $show_form true;
        if (!empty(
    $get['email']) && !empty($get['msg']) && !empty($get['name'])) {
            if (
    preg_match("/^[\w-]+(\.[\w-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i"trim($get['email']))) {
                
    $email preg_replace("/\r\n/"""$get['email']);
                
    $from preg_replace("/\r\n/"""$get['name']);
                
    $mail = new PHPMailer();
                
    $mail->IsSMTP();  
                
    $mail->Host "smtp.yourserver.com";  
                
    $mail->SMTPAuth true;  
                
    $mail->Username "postmaster@yourserver.com";
                
    $mail->Password "password"
                
    $mail->From "postmaster@yourserver.com";
                
    $mail->FromName "Webmaster";
                
    $mail->AddAddress("admin@yourserver.com");
                
    $mail->AddReplyTo($email$from);
                
    $mail->Subject "contact form using Xajax and phpmailer";
                
    $mail->Body $get['msg'];
                if (
    $mail->Send()) {
                    
    $error "The form is submitted and the mail is send.";
                    
    $show_form false;
                } else {
                    
    $error "There was a problem while sending the mail, please try again";
                }
            } else {
                
    $error "The entered e-mail address is not valid.";
            }
        } else {
            
    $error "At least one of the fields is empty...";
        }
        
    $data = (!$show_form) ? '<p class="contactMsg">'.$error.'</p>' '<p class="contactMsg">'.$error.'</p>'.$form;
        
    $objResponse->addAssign('contact_result''innerHTML'$data);
        return 
    $objResponse;
    }
    $xajax = new xajax();
    $xajax->registerFunction('myFunction');
    $xajax->processRequests();

    ?>
    <html>
    <head>
    <title>Form</title>

    <?php $xajax->printJavascript('xajax/'); ?>

    </head>

    <body>
    <div class="content1-container-1col">[INDENT]<div class="content-txtbox-noshade">
     <p>
    Please use the form below to get in touch with me. Please use a suitable subject to describe what you're writing about.
     </p>
    <?php echo '<div id="contact_result">'.$form.'</div>'?>
    </div>[/INDENT]</div>
    </body>
    </html>

+ 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. How to: Contact form with PHP
    By tttony in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 12-29-2008, 06:29 PM
  3. Javascript form to PHP
    By driveflexfuel in forum Scripts & 3rd Party Apps
    Replies: 3
    Last Post: 10-28-2008, 11:15 PM
  4. Addon Domain PHP Form Error
    By rockee in forum Free Hosting
    Replies: 2
    Last Post: 04-02-2008, 06:53 PM
  5. Help with contact form
    By dcoates in forum Programming Help
    Replies: 9
    Last Post: 03-08-2008, 04:52 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
x10hosting free hosting for the masses
dedicated servers