473,714 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I have a contact form that no longer "makes contact"

5 New Member
Good afternoon all!!

I am having a problem with a contact page that once sent the email to the admin's email but no longer does. I am at a complete loss as to why this occurred as I made NO changes to the page itself. The site once had hackers access it so there is specific code to eliminate this so maybe this is why it doesn't work anymore. Are there any code suggestions? Should I just create a new set of PHP to figure this problem out? I know how sometimes the code just gets a hickup and will no longer work. HELP!!!!

Thanks!!!
Megan
Apr 28 '11 #1
3 1524
JKing
1,206 Recognized Expert Top Contributor
Are there any errors?
Are the emails being caught in a spam filter?
Has your server been upgraded to a new version of php?

Without seeing any code, it is hard to suggest anything.
Apr 28 '11 #2
Megan Bade
5 New Member
When sending an email I do not receive any error messages.

I don't know if there is a spam folder or filter on the email account, but I have questioned the client about this.

I'm not sure if the server has gone through an upgrade recently.

Take a look at the code and let me know what you notice.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Everything in the php tags needs to be in the contact.php file
  3. error_reporting(0);
  4. //phpinfo();
  5.   // General defines
  6.     $to='user@domain.com'; // Email goes here
  7.     $messageSubject='Contact Inquiry'; // Email subject goes here
  8.     $success_message='<div class="success">Thank you for your inquiry. We will get back to you promptly.</div>'; // Message that displays after the message was successfully sent
  9.     $error_email='user@domain.com'; // Errors will be sent to this email
  10.     $crack_message='<div class="error">We have detected a possible crack attempt. Your details have been logged and sent to the webmaster.</div>'; // If a crack attempt is detected, display this message.
  11.     $incomplete_message='<div class="error">Oops... you have missed a required field. Please try again.</div>'; // Form was submitted but required fields are missing
  12.     $invalid_email='<div class="error">Oops... please check your email and make sure it is valid.</div>';
  13.     $unknown_error='<div class="error">An unknown error has occurred. Please try again.</div>'; // Unknown error message - catch all
  14.  
  15.     //mail($to,$messageSubject,$messageSubject,'From: '.$to."\r\n");
  16.     // You can include a second email that gets sent to another address as a Confirmation or copy email. Just set it to TRUE if you need to use it
  17.     $confirmation_copy = 0;
  18.  
  19.     if ($confirmation_copy == 1) {
  20.         $confirmationSubject='Confirmation email subject';
  21.       $confirmationBody='Static content that you want in the confirmation email body';
  22.     }
  23.  
  24.     // Fields are not parsed yet, empty the values
  25.     $name='';
  26.     $email='';
  27.     $phone='';
  28.     $message='';
  29.  
  30.     // Empty email relative variables
  31.     $body='';
  32.  
  33.     // The form has been submitted
  34.   if ($_POST['sent'] == "yes") {
  35.  
  36.         // Format the data
  37.     $name=addslashes($_POST['name']);
  38.         $email=addslashes($_POST['email']);
  39.         $phone=addslashes($_POST['phone']);
  40.         $message=addslashes($_POST['message']);
  41.  
  42.         // Create the email body
  43.          $body="
  44. Name: ".stripslashes($name)." 
  45. Email: ".stripslashes($email)." 
  46. Phone: ".stripslashes($phone)."
  47.  
  48. Comments:
  49. ".stripslashes($message)."\r\n".
  50. "\n\n".
  51.  
  52. "REMOTE IP:" . $_SERVER['REMOTE_ADDR'] 
  53. ."\n"
  54. ."REQUEST DATE: " .date("l dS of F Y h:i:s A") . " PST"
  55. . "\n"
  56. . "BROWSER:" . $_SERVER['HTTP_USER_AGENT'];
  57.  
  58.         // Validate
  59.     $valid_email=eregi('^([0-9a-z]+[-._+&])*[0-9a-z]+@([-0-9a-z]+[.])+[a-z]{2,6}$',$email);
  60.     $crack=eregi("(\r|\n)(to:|from:|cc:|bcc:)",$body);
  61.             if ($name && $email && $body && $valid_email && !$crack){
  62.                 $valid = true;
  63.             } else {
  64.                 $valid = false;
  65.             }
  66.  
  67.             // Make sure the required data is submitted and the email address is validated
  68.             if ($valid==true){
  69.  
  70.                 // Made it past validation and requirement checks, so send the email
  71.                 mail($to,$messageSubject,$body,'From: '.$email."\r\n");
  72.                     //if ($confirmation_copy == 1) {
  73.                         // If the confirmation email is enabled, send it
  74.                     //    mail($email,$confirmationSubject,$confirmationBody.$body,'From: '.$to."\r\n");
  75.                     //}
  76.  
  77.  
  78.                 // The Email was sent, display the success message
  79.                 $message = $success_message;
  80.  
  81.  
  82.         } elseif ($valid==false) { 
  83.  
  84.                 // Errors occurred
  85.  
  86.                 if ($crack) {
  87.                     // Crack attempt
  88.                     $details = 'A possible Crack attempt has been detected at '.$_SERVER['REQUEST_URI']."\n".'REMOTE IP:' . $_SERVER['REMOTE_ADDR'] ."\n"."REQUEST DATE: " .date("l dS of F Y h:i:s A") . " PST". "\n". "BROWSER:" . $_SERVER['HTTP_USER_AGENT'];
  89.                     $subject = 'Possible Crack attempt at '.$_SERVER['REQUEST_URI'];
  90.                     mail($error_email,$subject,$details,'From: '.$error_email."\r\n");
  91.                     $message = $crack_message;
  92.                 } else { 
  93.  
  94.                     if (!$valid_email) {
  95.  
  96.                         // Email is not valid
  97.                         $message = $invalid_email;
  98.  
  99.  
  100.                     } else {
  101.  
  102.                         // Form not complete - required fields were not submitted
  103.                         $message = $incomplete_message;
  104.  
  105.                     }
  106.                 }
  107.  
  108.             } else {
  109.  
  110.                 // Unknown error
  111.                 $message = $unknown_error;
  112.                 $details = 'A unknown error has occurred at '.$_SERVER['REQUEST_URI']."\n".'REMOTE IP:' . $_SERVER['REMOTE_ADDR'] ."\n"."REQUEST DATE: " .date("l dS of F Y h:i:s A") . " PST". "\n". "BROWSER:" . $_SERVER['HTTP_USER_AGENT'];
  113.                 $subject = 'Unknown error at '.$_SERVER['REQUEST_URI'];
  114.                 mail($error_email,$subject,$details,'From: '.$error_email."\r\n");
  115.  
  116.             }
  117.     } else {
  118.         // Does anything need to happen if the form is not sent? In most cases, leave this alone.
  119.         $message = $unknown_error;
  120.     }
  121. ?>
  122.  
Apr 28 '11 #3
JKing
1,206 Recognized Expert Top Contributor
Well error reporting has been turned off on line 3. Might want to turn that on, over a development server and check to see if there are any errors.

eregi is deprecated in php 5.3.0 other than that nothing jumps out at me.
Apr 28 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
944
by: Jason | last post by:
I'm struggling with this email code and I'm not php freak since I'm starting to learn php stuff. Could use some help... It seems that I get too many parse errors all over and cannot figure went wrong since most of these appears right to me... <?PHP $to = "scoobyood@jace41.com" ; $name = $_POST ;
49
2852
by: Ville Vainio | last post by:
I don't know if you have seen this before, but here goes: http://text.userlinux.com/white_paper.html There is a jab at Python, though, mentioning that Ruby is more "refined". -- Ville Vainio http://www.students.tut.fi/~vainio24
3
2122
by: Phil | last post by:
Hi everybody, I am a XSLT beginner and the following problem really makes me crazy ! I have a main "contacts.xml" document which contains references to several contact data XML files. My aim is to process the contacts in a single-pass XSLT process. That is why the "document()" function is what I need. I call the "document()" XPath function from a "for-each" instruction.
6
2515
by: dpr | last post by:
I have come accross a piece of C++ code with the construct: MyClass *c = new class MyClass(); Is there a difference between this and: MyClass *c = new MyClass(); ?
13
5074
by: Mike Austin | last post by:
Hi all. Just working on a small virtual machine, and thought about using vector iterators instead of pointer arithmetic. Question is, why does an iterator plus any number out of range not generate a out_of_range exception? Maybe this is a gcc issue? I'm using gcc version 3.3.3 (cygwin special). Here's the full sample code: #include <iostream>
9
6259
by: Hasan O. Zavalsiz | last post by:
Hi , i am trying to figure out which approach is better to use . let me explain the scenario. i am using the "Nortwind" database . in this database i have "Customers " table .The following is the two different ways to handle this table. CASE 1 : create a struct that encaplusates table "Customers" columns public struct structCustomers { public string CustomerID;
14
14176
by: Geoff Jones | last post by:
Hi I'm trying to use a class that I've written in a form. Unfortunately, when I write something like: Public x As New myClass I get the compile time error: "Type Expected". Indeed, the "squiggly" blue line does appear under myClass so I half expeced it. However, I had written
4
2246
by: Petterson Mikael | last post by:
Hi, We are still using RoseRT to generate c++ code. Has anyone out there gone from using this tool another more convetional tool? I am interested in all hints and pointers. cheers, //mikael
0
1339
by: active | last post by:
Sometimes when I After I click "Start Debugging" I get a "File not Found" Exception. Could not load file or assembly 'FormTesting, Version=1.0.2646.36738, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. Usually this happen right after (or maybe while) the Output window is showing the projects the IDE is checking.
3
2136
crystal2005
by: crystal2005 | last post by:
I found such eror message when i tried to test sending email. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /www/110mb.com/h/e/a/v/e/n/t/u/heaventure/htdocs/send_contact.php on line 10 Do we have to set something on the hosting server in order to be able to send message?? This is my code that i encountered the problem
0
8815
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8713
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9187
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7960
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5961
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2529
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.