Mounta1nGoat
16-11-2009, 08:32 PM
I coded this with the help of a tutorial and I changed a few things around but now recieve this error:
Warning: Cannot modify header information - headers already sent by (output started at /home/mounta1n/public_html/PHP/sendmail.php:18) in /home/mounta1n/public_html/PHP/sendmail.php on line 51
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Us</title>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="main">
<form method="post" action="sendmail.php"><h1>Contact Us</h1>
<p>Email:
<input name="email" type="text" />
<br />
Subject:
<input type="text" name="title" />
<br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea>
<br />
<input type="submit" />
</p>
</form>
</div>
<div id="banner"></div>
</body>
</html>
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$title = $_REQUEST['title'] ;
if ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {
?>
<html>
<head><title>Excuse me,</title></head>
<body>
<h1>Nice try,</h1>
<p>
But no.
</p>
</body>
</html>
<?php
}
if (!isset($_REQUEST['email'])) {
header( "Location: http://www.example.com/feedback.html" );
}
elseif (empty($email) || empty($message)) {
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Us</title>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="main">
<form method="post" action="sendmail.php"><h1>Contact Us</h1><br />
<h6>Oops you missed something, try again.</h6>
<p>Email:
<input name="email" type="text" />
<br />
Subject:
<input type="text" name="title" />
<br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea>
<br />
<input type="submit" />
</p>
</form>
</div>
<div id="banner"></div>
</body>
</html>
<?php
}
else {
mail( **********@*******.co.uk, "Mounta1nGoat.co.uk Title: $title",
$message, "From: $email" );
header( "Location: http://www.mounta1ngoat.co.uk/PHP/thanks.html" );
}
?>
Could somebody help out please?
Warning: Cannot modify header information - headers already sent by (output started at /home/mounta1n/public_html/PHP/sendmail.php:18) in /home/mounta1n/public_html/PHP/sendmail.php on line 51
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Us</title>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="main">
<form method="post" action="sendmail.php"><h1>Contact Us</h1>
<p>Email:
<input name="email" type="text" />
<br />
Subject:
<input type="text" name="title" />
<br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea>
<br />
<input type="submit" />
</p>
</form>
</div>
<div id="banner"></div>
</body>
</html>
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$title = $_REQUEST['title'] ;
if ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {
?>
<html>
<head><title>Excuse me,</title></head>
<body>
<h1>Nice try,</h1>
<p>
But no.
</p>
</body>
</html>
<?php
}
if (!isset($_REQUEST['email'])) {
header( "Location: http://www.example.com/feedback.html" );
}
elseif (empty($email) || empty($message)) {
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Us</title>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="main">
<form method="post" action="sendmail.php"><h1>Contact Us</h1><br />
<h6>Oops you missed something, try again.</h6>
<p>Email:
<input name="email" type="text" />
<br />
Subject:
<input type="text" name="title" />
<br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea>
<br />
<input type="submit" />
</p>
</form>
</div>
<div id="banner"></div>
</body>
</html>
<?php
}
else {
mail( **********@*******.co.uk, "Mounta1nGoat.co.uk Title: $title",
$message, "From: $email" );
header( "Location: http://www.mounta1ngoat.co.uk/PHP/thanks.html" );
}
?>
Could somebody help out please?