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
3 1514
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.
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. -
<?php
-
// Everything in the php tags needs to be in the contact.php file
-
error_reporting(0);
-
//phpinfo();
-
// General defines
-
$to='user@domain.com'; // Email goes here
-
$messageSubject='Contact Inquiry'; // Email subject goes here
-
$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
-
$error_email='user@domain.com'; // Errors will be sent to this email
-
$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.
-
$incomplete_message='<div class="error">Oops... you have missed a required field. Please try again.</div>'; // Form was submitted but required fields are missing
-
$invalid_email='<div class="error">Oops... please check your email and make sure it is valid.</div>';
-
$unknown_error='<div class="error">An unknown error has occurred. Please try again.</div>'; // Unknown error message - catch all
-
-
//mail($to,$messageSubject,$messageSubject,'From: '.$to."\r\n");
-
// 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
-
$confirmation_copy = 0;
-
-
if ($confirmation_copy == 1) {
-
$confirmationSubject='Confirmation email subject';
-
$confirmationBody='Static content that you want in the confirmation email body';
-
}
-
-
// Fields are not parsed yet, empty the values
-
$name='';
-
$email='';
-
$phone='';
-
$message='';
-
-
// Empty email relative variables
-
$body='';
-
-
// The form has been submitted
-
if ($_POST['sent'] == "yes") {
-
-
// Format the data
-
$name=addslashes($_POST['name']);
-
$email=addslashes($_POST['email']);
-
$phone=addslashes($_POST['phone']);
-
$message=addslashes($_POST['message']);
-
-
// Create the email body
-
$body="
-
Name: ".stripslashes($name)."
-
Email: ".stripslashes($email)."
-
Phone: ".stripslashes($phone)."
-
-
Comments:
-
".stripslashes($message)."\r\n".
-
"\n\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'];
-
-
// Validate
-
$valid_email=eregi('^([0-9a-z]+[-._+&])*[0-9a-z]+@([-0-9a-z]+[.])+[a-z]{2,6}$',$email);
-
$crack=eregi("(\r|\n)(to:|from:|cc:|bcc:)",$body);
-
if ($name && $email && $body && $valid_email && !$crack){
-
$valid = true;
-
} else {
-
$valid = false;
-
}
-
-
// Make sure the required data is submitted and the email address is validated
-
if ($valid==true){
-
-
// Made it past validation and requirement checks, so send the email
-
mail($to,$messageSubject,$body,'From: '.$email."\r\n");
-
//if ($confirmation_copy == 1) {
-
// If the confirmation email is enabled, send it
-
// mail($email,$confirmationSubject,$confirmationBody.$body,'From: '.$to."\r\n");
-
//}
-
-
-
// The Email was sent, display the success message
-
$message = $success_message;
-
-
-
} elseif ($valid==false) {
-
-
// Errors occurred
-
-
if ($crack) {
-
// Crack attempt
-
$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'];
-
$subject = 'Possible Crack attempt at '.$_SERVER['REQUEST_URI'];
-
mail($error_email,$subject,$details,'From: '.$error_email."\r\n");
-
$message = $crack_message;
-
} else {
-
-
if (!$valid_email) {
-
-
// Email is not valid
-
$message = $invalid_email;
-
-
-
} else {
-
-
// Form not complete - required fields were not submitted
-
$message = $incomplete_message;
-
-
}
-
}
-
-
} else {
-
-
// Unknown error
-
$message = $unknown_error;
-
$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'];
-
$subject = 'Unknown error at '.$_SERVER['REQUEST_URI'];
-
mail($error_email,$subject,$details,'From: '.$error_email."\r\n");
-
-
}
-
} else {
-
// Does anything need to happen if the form is not sent? In most cases, leave this alone.
-
$message = $unknown_error;
-
}
-
?>
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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();
?
|
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...
|
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...
|
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...
|
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
|
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'...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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...
|
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...
| |