473,320 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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 1514
JKing
1,206 Expert 1GB
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
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 Expert 1GB
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
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...
49
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...
3
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...
6
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
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...
9
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...
14
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...
4
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
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'...
3
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.