Basic form troubles

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 Graphics
"Goldfish
Home         Services         Portfolio         Contact

Testimonies

<?php include('testmonies.php'); ?>

Links

Contact

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?

Yes, the reason you are getting that Warning is to tell you it can’t connect to a sendmail server. I believe you can set them up, but I usually do it on a server that is hosted that has all this setup and meant for it. My local machine does send them, but seems to take forever.

As for the Security thing, that looks fine. But in order understand it, you should try to get an understanding of what things you want to prevent and then look into functions or process that can be used to stop those sort of things.

Sponsor our Newsletter | Privacy Policy | Terms of Service