0

what's wrong with my code?

<?php
error_reporting(0);
// ' Send me an email' script



if($_POST['submit'])

{
//get data from form
$name = $_POST['name'];
$message = $_POST['message'];

if($name&&$message)
{  // existance check
$namelen = 20;
$messagelen = 300;
if(strlen($name)<=$namelen&&strlen($message)<=$messagelen) // length check
{
// everything is ok!

//set SMTP in php.ini

ini_set("SMTP","localhost");
ini_set("smtp_port","465");
//set up the variables
$to = "gerbiepejo@yahoo.com\r\n";
$subject = "Email from Clarissa Jade Village Resort";
$header = "From:Jorus182@yahoo.com\r\n";


$body = "This is an email from $name\r\n$message";
mail($to, $subject, $body, $header);

die();
}

else
    die("Max length for name is $namelen, and max length for message is $messagelen!");
}
else
    die("You must enter your name <u>and</u> mesage");
}

?>

<html>

    <form action='sendemail.php' method='POST'>
        Name: <input type='text' name='name' maxlength='20'><br>
        Message:<br><textarea name='message'></textarea><p>
        <input type='submit' name='submit' value='Send'>
    </form>
</html>

Edited by Dani: Formatting fixed

4
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by alan_ot
0

1.check your smtp connection if you already connected.
2.check you have mail server installed or if you are using "xampp", check your mercury service.

0

you have:

<form action='sendemail.php' method='POST'>

try this:

<form action='' method='POST'>

it works with me

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.