20, July 2008

Safe contact form using xajax & PHP - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Miscellaneous scripts or snippets (Moderator: Olaf)
Topic: Safe contact form using xajax & PHP
« previous next »
Pages: 1 [2] Print

Author Topic: Safe contact form using xajax & PHP  (Read 2575 times)
Kill the googlebot
*
Posts: 6
36 credits
Members referred : 0


« Reply #20 on: Oct 22, 2007, 03:30:47 PM »

Thanks but I have tried that before but the form doesn t work

http://www.seogta.com/fmail.php Visit through proxy
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6279
38500 credits
Members referred : 374


It's time to use PHP5!


« Reply #21 on: Oct 22, 2007, 05:20:09 PM »

Thanks but I have tried that before but the form doesn t work

http://www.seogta.com/fmail.php Visit through proxy

I need to see the whole script


Last blog : 4th of July Lottery from TemplateMonster.com
Kill the googlebot
*
Posts: 6
36 credits
Members referred : 0


« Reply #22 on: Oct 23, 2007, 03:11:58 AM »

Here is the whole script


<?
require_once('phpmailer/class.phpmailer.php');
require ('xajax/xajax_core/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>';

//onsubmit="xajax_sendmail(xajax.getFormValues('form1'))

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->processRequest();

          ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd Visit through proxy">
<html>
 <head>
 <title>xajax example</title>
<?php
$xajax->printJavascript('xajax/');
 ?>


           </head>

           <body>
         <?php

      echo '<div id="contact_result">'.$form.'</div>';
      ?>


      </body>
      </html>
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6279
38500 credits
Members referred : 374


It's time to use PHP5!


« Reply #23 on: Oct 23, 2007, 07:35:18 AM »

looks good, do you get any error message?
maybe some variable is not filled, enable error reporting in your .htaccess file:

php_value display_errors On


Last blog : 4th of July Lottery from TemplateMonster.com
Kill the googlebot
*
Posts: 6
36 credits
Members referred : 0


« Reply #24 on: Oct 24, 2007, 02:21:32 AM »

I have done that, but I can not see any errors, can anybody have it working forward me a copy to test ... the only reason not to have it working is my host (assuming my code is correct), but this host a standard one (Cpanel Linux)
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6279
38500 credits
Members referred : 374


It's time to use PHP5!


« Reply #25 on: Oct 24, 2007, 09:34:15 AM »

sorry all code looks fine, the only things which is over is the host Sad

who is your hosting provider?


Last blog : 4th of July Lottery from TemplateMonster.com
Kill the googlebot
*
Posts: 6
36 credits
Members referred : 0


« Reply #26 on: Oct 25, 2007, 05:47:20 AM »

I have 4 hosts, I tried the scripts on a shared account with HostForWeb.com and Dedicated server from HostForWeb as well but it did not work .. I can try it on the other two host, but I dont think it is a host issue .. the form doesn respond at all to the submit button. I would like to repeat my request for you to send me ready to use files to try them .. may be I missed something
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6279
38500 credits
Members referred : 374


It's time to use PHP5!


« Reply #27 on: Oct 25, 2007, 07:13:29 AM »

I have 4 hosts, I tried the scripts on a shared account with HostForWeb.com and Dedicated server from HostForWeb as well but it did not work .. I can try it on the other two host, but I dont think it is a host issue .. the form doesn respond at all to the submit button. I would like to repeat my request for you to send me ready to use files to try them .. may be I missed something
if your dedicated host doesn't work it shouldn't be a hosting problem. I will try your example on my own server and we will see...


Last blog : 4th of July Lottery from TemplateMonster.com
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6279
38500 credits
Members referred : 374


It's time to use PHP5!


« Reply #28 on: Oct 25, 2007, 07:22:32 AM »

hey wait...

I think you're using a diff. xajax version:
require ('xajax/xajax_core/xajax.inc.php');

I remember be that the author of xajax has changed several things in a newer version.

Try using xajax ver. Version 0.2.4 (stable release)


Last blog : 4th of July Lottery from TemplateMonster.com
Kill the googlebot
*
Posts: 6
36 credits
Members referred : 0


« Reply #29 on: Oct 26, 2007, 06:09:13 AM »

Thanks for your time, I give up Smiley  .. I will look for something else
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6687
Tags : xajax php Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: 1 [2] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Miscellaneous scripts or snippets (Moderator: Olaf)
Topic: Safe contact form using xajax & PHP
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jul 20, 2008, 06:24:12 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 35.668
Total Topics: 7.373
Total Members: 3.693
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: talelmouaada

12 Guests, 2 Users online :

5 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.