Can someone please help me to fix the problem that I have at
http://www.sandragreen.com/guestbook.php.
Quote:
|
Your request could not be sent. Sorry!
|
Based on the guestbook.
php code, how can I freely add more fields or remove more fields?
Any inputs will be much appreciate!
http://www.sandragreen.com/Feedback.html
- Code: Select all
<html>
<head>
<title>Guest Book</title>
<style>
.title{ font-family:Arial, Helvetica, sans-serif; font-size:larger; font-weight:bold; background-color:#5c8f00; color:fff; padding:20px; margin-left:auto; margin-right:auto; width:50%; border:solid 1px #000000; }
.face{background-color:#e5ebb8; padding:20px ;margin-left:auto; margin-right:auto; width:50%; border-left:solid 1px #ff9900; border-right:solid 1px #ff9900; border-top:solid 2px #cc9933; border-bottom:solid 1px #ff9900; }
.T-face{background-color:#FFFFCC; padding:20px; margin-right:auto; width:50%; border:#FF9900;}
.typer{font-family:Arial, Helvetica, sans-serif; font-size:12px;font-weight:bold; color:#000;}
.data{margin-left:auto; margin-right:auto; }
</style>
</head>
<body>
<div class="title"><h1>Guest Book</h1></div>
<form action="guestbook.php" method="POST" enctype="multipart/form-data" class="face">
<div class="data"><span class="typer">To:</span> <input type="text" name="to" value="" /><br />
<span class="typer">From:</span> <input type="text" name="from" value="" /><br />
<span class="typer">Subject:</span> <input type="text" name="subject" value="" /></div>
<div class="data">
<span class="typer">Name:</span>
<input type="text" name="name" value=""><br />
<span class="typer">Telephone:</span><input type="text" name="telephone" value=""><br />
<span class="typer">Address:</span><input type="text" name="address" value=""><br />
</div>
<div class="data"><span class="typer">Message:</span><br />
<textarea cols="50" rows="20" name="message"></textarea></div>
<div class="data"><span class="typer">File Attachment:</span><input type="file" name="fileatt" /></div>
<div class="data"><input type="submit" value="Send" /></div>
</form>
</body>
</html>
http://www.sandragreen.com/guestbook.php- Code: Select all
<?php
// Read POST request params into global vars
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$name = $_POST['name'];
$telephone = $_POST['telephone'];
$address = $_POST['address'];
$message = $_POST['message'];
// Obtain file upload vars
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$headers = "From: $from";
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
// Send the message
$ok = @mail($to, $subject, $name, $telephone, $address, $message, $headers);
if ($ok) {
echo "<p>Thank you for sending your comments, we'll contact you soon!</p>";
} else {
echo "<p>Your request could not be sent. Sorry!</p>";
}
?>