I am new to building website but trying my hand in building a personal website for me and my family.
I am trying to run a php code from a html form (Contact Us). The Codes are as follows:-
1. Code for Contact Us.htm
<html>
<HEAD>
<link rel="stylesheet" type="text/css" href="style.css" media="screen, print" />
<META HTTP-EQUIV="EXPIRES" CONTENT="0">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta name="Copyright" content="eAngan">
<meta name="Language" content="English">
</head>
<body rightmargin="2" background="background3.gif">
<table width="80%" border="0" cellpadding="5" cellspacing="2" align="center">
<tr><td align="center"><strong>Contact Us</strong></td></tr>
<tr><td>
<form name='contactus' action='mail.php' onSubmit='return doSearch(1)' method="post" enctype="multipart/form-data">
<table width="80%" border="0" cellpadding="1" cellspacing="0" align="center">
<tr><td align="right" width="33%">Your name/td><td><input name="name" type="Text" size="50" maxlength="100"></td></tr>
<tr><td align="right">*Your e-mail/td><td><input name="email" type="Text" size="35" maxlength="100"></td></tr>
<tr><td align="right" width="33%">Subject/td><td><input name="subject" type="Text" size="40" maxlength="100" value=""></td></tr>
<tr><td align="right">Your message/td><td>
<textarea name="message" cols="50" rows="8" wrap="soft"></textarea></td></tr>
<tr>
<td align="right" width="33%">To/td>
<td>
<select name="to">
<option value="1" selected>Shyamal Das
<option value="2" >Paromita Das
<option value="3" >Shreya Das
</select>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td align="right" width="33%">Attachment : </td><td><input name="fileatt" type="file" size="40" maxlength="100" value=""></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<input name="action" type="hidden" value="submit">
</td>
</tr>
</table>
</td></tr>
<tr bgcolor="#e0e0e0"><td align="center"><input type="Submit" value="SEND"> <input type="Reset" value="Clear all fields"></td></tr>
</form>
</table>
<script language="JavaScript">
function doSearch(canReturn)
{
var canSubmit = 0;
var fieldVal = new String("" + document.forms['contactus'].elements['name'].value);
if (fieldVal == "")
{
alert('Please enter your name.');
document.forms['contactus'].elements['name'].focus();
if (canReturn == 1)
{
return false;
}
}
else { canSubmit = 1; }
var fieldVal = new String("" + document.forms['contactus'].elements['email'].value);
if (fieldVal == "")
{
alert('Please enter an e-mail address.');
document.forms['contactus'].elements['email'].focus();
if (canReturn == 1)
{
return false;
}
}
else { canSubmit = 1; }
var fieldVal = new String("" + document.forms['contactus'].elements['subject'].value);
if (fieldVal == "")
{
alert('Please enter a subject for your message.');
document.forms['contactus'].elements['subject'].focus();
if (canReturn == 1)
{
return false;
}
}
else { canSubmit = 1; }
var fieldVal = new String("" + document.forms['contactus'].elements['message'].value);
if (fieldVal == "")
{
alert('Please enter a message.');
document.forms['contactus'].elements['message'].focus();
if (canReturn == 1)
{
return false;
}
}
else { canSubmit = 1; }
if (canSubmit == 1)
{
document.forms['contactus'].submit();
}
}
</script>
</body>
</html>
2. Code for mail.php
<HTML>
<TITLE> This is the page for Festivals</TITLE>
<HEAD>
<link rel="stylesheet" type="text/css" href="style.css" media="screen, print" />
<META HTTP-EQUIV="EXPIRES" CONTENT="0">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta name="Copyright" content="eAngan">
<meta name="Language" content="English">
</head>
<body background="background3.gif">
<?php
// Read POST request params into global vars
$from = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = $_POST['to'];
if ($to == 1)
$sendto = "shyamal.das@eangan.com";
if ($to == 2)
$sendto = "paromita.das@eangan.com";
if ($to == 3)
$sendto = "shreya.das@eangan.com";
// Obtain file upload vars
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$headers = "$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($sendto, $subject, $message, $from);
if ($ok) {
?>
<table align="center" width="80%" border="0" cellpadding="5" cellspacing="2">
<tr><td>
<br>The following message has been sent to <?php echo $sendto?><br><br>
</td></tr>
<tr><td bgcolor="#e0e0e0">
<b>From : </b><?php echo $_POST['email']?><br>
<b>Subject : </b><?php echo $subject?><br><br>
</td></tr>
<tr><td>
Thank you for your feedback and response. <a href='javascript:history.go(-2);'><b>Click here to continue browsing eAngan</b></a>.
</td></tr>
</td></tr>
</table>
<?
} else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
?>
</body>
</html>
When I tested on my localhost (Apache Server / PHP) it functioned OK. But when loaded on to my website it gives the following errors :
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
--------------------------------------------------------------------------------
Please try the following:
Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
If you reached this page by clicking a link, contact the Web site administrator to alert them that the link is incorrectly formatted.
Click the Back button to try another link.
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
--------------------------------------------------------------------------------
Technical Information (for support personnel)
Go to Microsoft Product Support Services and perform a title search for the words HTTP and 404.
Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for topics titled Web Site Setup, Common Administrative Tasks, and About Custom Error Messages.
Where as I have confirmed and double checked that I have loaded mail.php on the server.
Please help, I don't know how to solve.


/td><td><input name="name" type="Text" size="50" maxlength="100"></td></tr>



Bookmarks