Hello I am having a problem with forms. I know they are easy for some people, but I am new. I am trying to make a simple feedback form. Hear is what I have so far…
[php]<?php
//process the email
if (array_key_exists(‘send’, $_POST)) {
$to = ‘[email protected]’; //use your own email
$subject = ‘Project Idea’;
//process the $_POST variables
$name = $_POST[‘name’];
$email = $_POST[‘comments’];
//build the message
$message = “Name: $namenn”;
$message .= “Email: $emailnn”;
$message .= “Project Idea: $comments”;
//limit line length to 55 characters
$message = wordwrap($message, 55);
//send it
$mailSent = mail($to, $subject, $message);
}
?>
Goldfish GraphicsContact
Name:
Email:Prodject Description:
<?php if ($_POST && !$mailSent) { ?>
Sorry, there was a problem sending your message. Please check to make sure you filled out all the required entries.
<?php } elseif ($_POST && $mailSent) { ?>Your message has been sent. Thank you.
<?php } ?>
The problem is it’s not actually sending anything to my email. This might be because I am doing it on a local host, the other thing is whenever I summit any kind of information this error message pops up at the top of my site…
Warning: mail() [function.mail]: Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in D:wampwwwGoldfish Graphicscontact.php on line 21
I want to know how to make that not happen, I want to know how to make the information actually go to my email, and I don’t really understand how to make my forms safe from hackers. I basically went through a tutorial and found this.
<? function secured($val) { if(empty($val) or strlen($val) > 40) { return false; } else { $val = strip_tags( trim(($val) ) ) ; $val = escapeshellcmd($val); return stripslashes($val); } } ?>[/php]I have that saved in a php file as security and in my code above you can see I have the name and id of the input fields as security. Does this work?