Jump to content

Contact Form on site using php


2vmonster

Recommended Posts

Hello all! My first post here and was needing a little help. I have a contact form on a site for contacting the owner and cannot get it to send... the functions seem to work and it says email has been sent but I never receive it. This maybe a dumb question but i figured i would ask.

 

-I am running Mamp locally to test.. will this be the issue?

 

code:

 

<?php

$dontsendemail = 0;

$possiblespam = FALSE;

$strlenmessage = "";

$email = $_REQUEST['email'];

$message = $_REQUEST['message'];

$subject = "!!!Website Contact Form!!!";$emailaddress = "[email protected]";

 

function checkemail($field) {

// checks proper syntax

if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $field))

{

die("Improper email address detected. Please hit your browser back button and try again.");

return 1;

}

}

function spamcheck($field) {

if(eregi("to:",$field) || eregi("cc:",$field) || eregi("\r",$field) || eregi("\n",$field) || eregi("%0A",$field)){

$possiblespam = TRUE;

}else $possiblespam = FALSE;

if ($possiblespam) {

die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again.");

return 1;

}

}

function strlencheck($field,$minlength,$whichfieldresponse) {

if (strlen($field) < $minlength){

die($whichfieldresponse);

return 1;

}

}

 

if ($dontsendemail == 0) $dontsendemail = checkemail($email);

if ($dontsendemail == 0) $dontsendemail = spamcheck($email);

if ($dontsendemail == 0) $dontsendemail = spamcheck($subject);

if ($dontsendemail == 0) $dontsendemail = strlencheck($email,10,"The email address field is too short. Please hit your browser back button and check your entry.<br />");

 

if ($dontsendemail == 0) $dontsendemail = strlencheck($message,5,"The message field is too short. Please hit your browser back button and check your entry.<br />");

if ($dontsendemail == 0) $dontsendemail = strlencheck($emailaddress,8,"You have not selected a recipient of your message. Please hit your browser back button and check your entry.<br />");

if ($dontsendemail == 0) {mail($emailaddress,"Subject: $subject",$message,"From: $email" ); echo "Thank You.. Slim has received your message!! Use back in your browser window to return to the previous page!";}

?>

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/113672-contact-form-on-site-using-php/
Share on other sites

create a page like this

<?php
phpinfo();
?>

that will print out most if the settings from your php.ini file

if your on linux you want a line like

sendmail_path = 	/usr/sbin/sendmail -t -i

or something similar

on windows i think you want

SMTP = smtp.your.isp.com
smtp_port = 25

 

Scott.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.