Expand|Select|Wrap|Line Numbers
- <?php
- //process the email
- if (array_key_exists('send', $_POST)) {
- $to = 'goldfishgraphics@gmail.com'; //use your own email
- $subject = 'Project Idea';
- //process the $_POST variables
- $name = $_POST['name'];
- $email = $_POST['comments'];
- //build the message
- $message = "Name: $name\n\n";
- $message .= "Email: $email\n\n";
- $message .= "Project Idea: $comments";
- //limit line length to 55 characters
- $message = wordwrap($message, 55);
- //send it
- $mailSent = mail($to, $subject, $message);
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtmll/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
- <title>Goldfish Graphics</title>
- <link type="text/css" rel="stylesheet" href="Goldfish.css" />
- <style type="text/css">
- <!--
- A {text-decoration:none}
- -->
- </style>
- </head>
- <body>
- <div id="container">
- <div id="banner">
- <img src="images/banner.jpg" alt= "Goldfish Graphics Banner Image" />
- </div>
- <div id="navigation">
- <div id="hvan">
- <a href="index.php">Home</a> <a href="services.php">Services</a> <a href="portfolio.php">Portfolio</a> <a href="contact.php">Contact</a>
- </div>
- </div>
- <div id="sidebar">
- <div id="texto">
- <h4 class="sidebar"> Testimonies</h4>
- <p>
- <?php include('testmonies.php'); ?>
- </p>
- </div>
- <h4>Links</h4>
- <div id="links">
- <div class="nav">
- <p>
- <a href="#">Pixel2Life</a>
- <br />
- <a href="#">Link</a>
- <br />
- <a href="#">Link</a>
- <br />
- <a href="#">Link</a>
- </p>
- </div>
- </div>
- </div>
- <div id="content">
- <div id="text">
- <h2>Contact</h2>
- <p id="home">
- <form id="feedback" method="post" action="">
- <p>
- <label for="name">Name:</label>
- <input name="security" id="security" type="text" class="name" />
- </p>
- <label for="email">Email:</label>
- <input name="security" id="security" type="text" class="email" />
- <p>
- <label for="comments">Prodject Description:</label>
- <textarea name="security" id="security" cols="54" rows="5">
- </textarea>
- </p>
- <p>
- <input name="send" id="send" type="submit" value="Submit" />
- </p>
- </form>
- <?php
- if ($_POST && !$mailSent) {
- ?>
- <p class="warning">Sorry, there was a problem sending your message. Please check to make sure you filled out all the required entries.</p>
- <?php
- }
- elseif ($_POST && $mailSent) {
- ?>
- <p><strong>Your message has been sent. Thank you.</strong></p>
- <?php } ?>
- </p>
- <p id="news">
- </p>
- </div>
- </div>
- <div id="footer">
- </div>
- </div>
- </body>
- </html>
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:\wamp\www\Goldfish Graphics\contact.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.
Expand|Select|Wrap|Line Numbers
- <?
- function secured($val)
- {
- if(empty($val) or strlen($val) > 40)
- {
- return false;
- } else {
- $val = strip_tags(
- trim(($val)
- )
- )
- ;
- $val = escapeshellcmd($val);
- return stripslashes($val);
- }
- }
- ?>