28, May 2012

Contact Form Issues - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Contact Form Issues
« previous next »
Pages: [1] 2 Print
Instabuck - The easy way to sell digital products online

Author Topic: Contact Form Issues  (Read 3932 times)
World Wide Whale
***
Gender: Female
Posts: 154
1052 credits
Members referred : 0



« on: Jun 12, 2007, 08:21:20 pm »

I have a PHP contact form on a friends website.  After you hit send it says it sent successfully, but it never comes through.....

Any suggestions?

Main Page Code
Code:
<?php

require ('config.php');
require (
'contactForm.php');
require (
'email.php');
require (
'validateFormData.php');
require (
'cleanStrings.php');

if(isset(
$_POST['send_form'])) {

$validator = new validateFormData();

$name $_POST['name'];
$email $_POST['email'];
$subject $_POST['subject'];
$message nl2br($_POST['message']);
$error '';


if(!$validName $validator->validateInput("fullname"$name)) 
{
$error .=  "<li>".$invalid_full_name_message."</li>\n";
}
if(!$validEmail $validator->validateInput("email"$email))
{
$error .=  "<li>".$invalid_email_address_message."</li>\n";
}
if(!$validSubject $validator->checkTextLength($subject3100)) 
{
$error .=  "<li>".$invalid_subject_message."</li>\n";
}
if(!$validMessage $validator->checkTextLength($message61000))
{
$error .=  "<li>".$invalid_comment_message."</li>\n";
}
 

if(!empty($error)) 
{
$cleanMessage = new cleanStrings();
$cleanMessage->setStringToClean($message);
$message $cleanMessage->cleanBR();  


else 
{
$formFields = array($name,$subject,$message); //set array of form fields to be cleaned
$cleanedFormFields = array(); //set array that will hold clean fields


$cleanForm = new cleanStrings();

$cleanedFormFields $cleanForm->cleanDirtyFormFields($formFields);


$name $cleanedFormFields[0];
$subject $cleanedFormFields[1];
$message $cleanedFormFields[2];


$sendEmail = new email($myEmail,$subject,$message,$email,$name);


$name "";
$email "";
$subject "";
$message "";


if(!$sendEmail
{
$notSent true;

else 
{
$sent true;
}

}

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="Design.css" rel="stylesheet" type="text/css" />
<LINK REL="SHORTCUT ICON" HREF="favicon.ico" type="image/x-icon">
</head>

<body>
   
        <?php echo $myPageHeading?></h1>
<?php if($myGreeting) { echo "<p>".$myGreeting."</p>\n"; } ?>
<?

if($error) {
?>
            <div id="error_message">
<?php
                    
if($error !== ''
                    {
                        if(
$errorMessageWarning) { echo "<p>".$errorMessageWarning."</p>\n"; }
                        echo 
"<ul>\n";
                        echo 
$error;
                        echo 
"</ul>\n";
                    }

                
?>

             </div>
         <?php 
echo "\n"; } 
?>

<?php 

if( ($notSent) || ($sent) )
{
?>

<?php
if($sent
{
echo "<p>".$email_successfuly_sent."</p>\n";
}
else 
{
echo "<p>".$email_undeliverable."</p>\n";
}
?>

<?php


if( (!$sent) || ($error) ) 
{
echo "<div id=\"contact_form\">\n";
displayContactForm();
echo "</div>\n";
}
?>

       
    </div>

Here is the config file
Code:
<?php

//config.php
/***********************************************
Personalize the contact form by editing
the details below. 
************************************************/

/* 1. Fill in your email address, the location of the CSS file you'd like to use for the form, a
page title (seen in the top left corner of the browser window), a page heading and an optional greeting. */

$myEmail 'name@isp.com'; /* The email address you would like to use */
$myCSSfile 'Design.css';  /* The location of your CSS file */
$myPageTitle ''; /* The title of this page */
$myPageHeading ''; /* The page heading */

/* The greeting to display above the form: */
/* If you'd like no greeting to appear remove the text and leave ""; instead */
$myGreeting '';

/* 2. Set your custom Error messages.*/

/* If there is an error show this 'warning' message: */
/* If you'd like no warning to appear remove the text and leave ""; instead */
$errorMessageWarning 'Sorry, but there was a problem(s) with your submission:'

/* The following are used to display error messages for each type of error */
$invalid_full_name_message 'Please correct your Name'; /* Inavlid Full Name message */
$invalid_email_address_message 'Please correct your Email Address'; /* Invalid Email Address message */
$invalid_subject_message 'Please correct your Email Subject'; /* Invalid Subject message */
$invalid_comment_message 'Please correct your Message'; /* Invalid Comment message */


/* 3 Set your custom email messages for sent and not sent */

/* If the email was successfully sent display the following message: */
$email_successfuly_sent'<strong>Your message was sucessfully sent!</strong>';

/* If the email is undeliverable display the following message: */
$email_undeliverable 'Your message <strong>could not be sent</strong>. Please try again.';

/*** That's it!! You're done! ***/

?>

I am pretty sure the error lies somewhere in those files I just can't seem to find it. 

Thanks in advance for all of your help!
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Jun 12, 2007, 08:26:33 pm »

Where is the form content?

What is the problem you have?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Jun 12, 2007, 08:32:11 pm »

what is the content from the mail script

and try different email addresses (something other then hotmail and gmail)

World Wide Whale
***
Gender: Female
Posts: 154
1052 credits
Members referred : 0



« Reply #3 on: Jun 12, 2007, 08:35:15 pm »

The problem is that the form says it sent, but the email never comes through.  I have tried 3 different email addresses, one through a GoDaddy account, one through a company account & another gmail account.

Here is the contact form code....
Code:
<?php

/********************************
contactForm():
Generates a standard contact form: Name, Email Address, Subject, Message
********************************/

function displayContactForm() {

global 
$name;
global 
$email;
global 
$subject;
global 
$message;

?>


<form method="post" action="<?php $_SERVER["../displayFuncs/PHP_SELF"]; ?>">
<p>Your Name<br />
<input type="text" name="name" size="15" maxlength="50" tabindex="1" accesskey="n" value="<? echo stripslashes($name); ?>" />

<br />Your Email Address<br />
<input type="text" name="email" size="15" maxlength="50" tabindex="2" accesskey="e" value="<? echo $email; ?>" />

<br />Phone<br />
<input type="text" name="subject" size="15" maxlength="14" tabindex="3" accesskey="s" value="<? echo stripslashes($subject); ?>" />

<br />Message<br />
<textarea rows="3" cols="13" name="message" tabindex="4" accesskey="m"><? echo stripslashes($message); ?></textarea></p>

<input type="submit" value="Send" name="send_form" tabindex="5" />

</form>
<?
} // end function
?>
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Jun 12, 2007, 08:38:50 pm »

i asked for the email code Wink

World Wide Whale
***
Gender: Female
Posts: 154
1052 credits
Members referred : 0



« Reply #5 on: Jun 12, 2007, 09:11:08 pm »

Oops, sorry
Code:
<?php

class email {

var $email_to;
var $email_from;
var $email_subject;
var $email_message;
var $email_headers;

function 
email($to,$subject,$message,$headers,$email_from) {

$ip $_SERVER['REMOTE_ADDR'];
$browser $_SERVER['HTTP_USER_AGENT'];
$refer =  $_SERVER['HTTP_REFERER'];

$this->email_to $to;
$this->email_from $email_from;
$this->email_subject $subject;

$this->email_message $message;
$this->email_message .= "\n\n\n------------------------------------------------------\n";
$this->email_message .= "IP: ".$ip ."\n";
$this->email_message .= "Referrer: ".$refer."\n";
$this->email_message .= "Browser: ".$browser."\n";

//$this->email_headers = "From:". $this->email_from . "<" . $headers . ">\r\nContent-Type: text/html; charset=iso-8859-1";
$this->email_headers "From:"$this->email_from "<" $headers ">\r\n";

if(!mail($this->email_to,$this->email_subject,$this->email_message,$this->email_headers)) {
return false;
} else {
return true
}

}
//end

// end class

?>
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Jun 12, 2007, 09:45:18 pm »

ok, do you tried to send a mail to some non webmail account (some pop account from your ISP for example)?

Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 619
5660 credits
Members referred : 0


www.dg9.org


« Reply #7 on: Jun 13, 2007, 03:46:04 am »

I'm actually having problems with my mail sending too... I guess mine is caused by being blocked as spam since my shared hosts has been used by spammers to send out spam. My problem would now turn to how to get my server off the black-list...

http://www.dg9.org , Just Visit...
Partners:
http://www.resume-fix.com , Free Resumes

Last blog : Archos: Where are you?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Jun 13, 2007, 08:03:15 am »

I'm actually having problems with my mail sending too... I guess mine is caused by being blocked as spam since my shared hosts has been used by spammers to send out spam. My problem would now turn to how to get my server off the black-list...

yes thats a big problem, since Google has a kind of spam filter which is based on votes. The best thing is to use SMTP mail from a server which is used only by yourself.

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #9 on: Jun 13, 2007, 12:23:07 pm »

Some hosts do not allow the use of mail()

In that case you should use SMTP (phpMailer can help with that)

Also many mail servers do not have reverse DNS entries so email will never be delivered.

I would advice you to first contact your host.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #10 on: Jun 13, 2007, 12:51:55 pm »

Some hosts do not allow the use of mail()

In that case you should use SMTP (phpMailer can help with that)

Also many mail servers do not have reverse DNS entries so email will never be delivered.

I would advice you to first contact your host.

in that case the script will show some error (check the first file Nick)

World Wide Whale
***
Gender: Female
Posts: 154
1052 credits
Members referred : 0



« Reply #11 on: Jun 14, 2007, 04:34:13 pm »

ok, do you tried to send a mail to some non webmail account (some pop account from your ISP for example)?

I have sent it to a GoDaddy Account, a Gmail Account & an account from her real estate company.  None of them seem to be working, we have checked the spam folders too.  I use the same script on another site & it works fine.  All I changed was the email address, the design file and the header & message, it was using a gmail account too.  Works perfectly....

I have temporarily taken it down so she doesn't loose messages. 

Any advice would be appreciated.

Thanks
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #12 on: Jun 14, 2007, 07:23:18 pm »


I have sent it to a GoDaddy Account, a Gmail Account & an account from her real estate company.  None of them seem to be working, we have checked the spam folders too.  I use the same script on another site & it works fine.  All I changed was the email address, the design file and the header & message, it was using a gmail account too.  Works perfectly....

I have temporarily taken it down so she doesn't loose messages. 

Any advice would be appreciated.

Thanks

than check if the mail() function is allowed by your hosting provider (or use a simple mail() example from the manual)

World Wide Whale
***
Gender: Female
Posts: 154
1052 credits
Members referred : 0



« Reply #13 on: Jun 14, 2007, 07:34:48 pm »

It's on the same host as the one that works....
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #14 on: Jun 14, 2007, 07:39:29 pm »

ok try:

if (mail('your@mail.com''some subject''Hello world!')) echo 'mail send';?>

in some new test script and tell me what you see...

World Wide Whale
***
Gender: Female
Posts: 154
1052 credits
Members referred : 0



« Reply #15 on: Jun 14, 2007, 08:13:19 pm »

I am sorry I am working on about 5 different projects right now....  Where should I put that script?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #16 on: Jun 14, 2007, 09:57:18 pm »

I am sorry I am working on about 5 different projects right now....  Where should I put that script?

create a new script with only this code (it's a test)

World Wide Whale
***
Gender: Female
Posts: 154
1052 credits
Members referred : 0



« Reply #17 on: Jun 14, 2007, 10:30:20 pm »

Sorry, you caught me at a bad time earlier.... 
World Wide Whale
***
Gender: Female
Posts: 154
1052 credits
Members referred : 0



« Reply #18 on: Jun 14, 2007, 10:55:44 pm »

It said it sent, but I haven't gotten anything yet (about 15-20 minutes maybe). 

You can take a look at it, http://www.2706bakerplace.info/TESTEMAIL.php
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #19 on: Jun 14, 2007, 11:04:27 pm »

It said it sent, but I haven't gotten anything yet (about 15-20 minutes maybe). 

You can take a look at it, http://www.2706bakerplace.info/TESTEMAIL.php

do you get a mail if you use this test file on that other website where the script is working?

Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6793
Tags : php Contact Form Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] 2 Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Contact Form Issues
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 07:53:49 pm





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!






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