Yanathin: You have to give some detailed information about your server setup. This might help us to understand what you are trying to do. You don’t have to answer in technical terms. Just answer the following question after make it sure.
1. Are you put this PHP Form in a web server, and want to send email to that particular domain web-mail?
2. Is this PHP Form will sent mail to some other mail service provider’s mail system, like gmail, yahoo mail etc.?
3. Is this are going to run from localhost (mean from your own computer), and send mail to gmail?
4. Or none of the above?
This will create a simple form with single input field and a submit button to send some data of the browser:
PHP Code:
<?PHP
function send_mail(){
global $error;
if(isset($_POST["message"]) && $_POST["message"]!=="message"){
// here goes the mail or phpMailer function
$error = "Thank You : Mail has been send.";
}else{
$error="ERROR";
}
}
$currentFile = $_SERVER["PHP_SELF"];
$path = Explode('/', $currentFile);
$send=$path[count($path)-1];
$email="";
if(!isset($_GET["content"])){
$message="message";
}elseif(isset($_POST["email"])){
$message=$_POST["message"];
}elseif(!isset($_POST["email"]) && isset($_GET["content"])){
$message="message";
}
$error="";
if(isset($_POST["email"])){
$email=$_POST["email"];
$message=$_POST["message"];
if(!$email){
$error="ERROR";
}else{
send_mail();
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Mail Form</title>
</head>
<body style="margin:0px;">
<div style="margin:auto; width:350px; padding:5px;">
<div><?PHP echo $error; ?></div>
<form action="<?PHP $send; ?>?content" method="post" >
Email: <br />
<input name="email" type="text" id="email" value="<?PHP echo "$email"; ?>" />
<br/>
Message: <textarea name="message" id="message" cols="50" rows="10" ><?PHP echo "$message"; ?></textarea>
<br/>
<input name="submit" type="submit" value="Submit" />
</form>
</div>
</body>
</html>
Best Wishes