Dear Friends,
i am making this form but i dont understand how to add more fields on gmail body message. name, email, attachment is work fine but Qualification is not print to email body and add more fields like: Age, Facebook ID, Gender, Phone Number, Country, City, Show time, Skype ID.. please fix this form thank you
i am making this form but i dont understand how to add more fields on gmail body message. name, email, attachment is work fine but Qualification is not print to email body and add more fields like: Age, Facebook ID, Gender, Phone Number, Country, City, Show time, Skype ID.. please fix this form thank you
Code:
<?php
/* Mailer with Attachments */
$action = $_REQUEST['action'];
global $action;
function showForm() {
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body style="padding:3px; margin:0px;" bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" border="0" width="440">
<tr><td style="height:10px"></td></tr>
<tr>
<td colspan="2" style="text-align:justify; line-height:15px;" class="body">
<form name="send" method="POST" action="<?=$_SERVER['PHP_SELF']?>" enctype="multipart/form-data">
<input type="hidden" name="action" value="send" />
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="23%" class="body"> Name</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="from_name" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Email</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="from_email" class="textfield"></td>
</tr>
<tr>
<td width="23%" class="body"> Age</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="age" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Facebook ID</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="fbid" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Gender</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="gender" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Phone Number</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="phnumb" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Country</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="country" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> City</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="city" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Show time</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="time" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Skype ID</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="text" name="skype" class="textfield"></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Qualification</td>
<td width="3%" class="body">:</td>
<td width="74%"><textarea cols="16" name="body"></textarea></td>
</tr>
<tr><td style="height:3px"></td></tr>
<tr>
<td width="23%" class="body"> Resume</td>
<td width="3%" class="body">:</td>
<td width="74%"><input type="file" name="attachment"></td>
</tr>
<tr><td style="height:10px"></td></tr>
<tr>
<td colspan="3" align="center">
<input type="submit" value="Send" name="submit" onClick="return validate();"> <input type="reset" value="Reset" name="reset">
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
</table>
</body>
</html>
<?php
}
function sendMail() {
$to_name = "Recipient Name";
$from_name =($_POST['from_name']);
$subject = "Resume Attached";
$body = stripslashes($_POST['body']);
$to_email = "zain6061@gmail.com";
$attachment = $_FILES['attachment']['tmp_name'];
$attachment_name = $_FILES['attachment']['name'];
if (is_uploaded_file($attachment)) { //Do we have a file uploaded?
$fp = fopen($attachment, "rb"); //Open it
$data = fread($fp, filesize($attachment)); //Read it
$data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can emailed
fclose($fp);
}
$bad_headers = array(
"/to\:/i",
"/from\:/i",
"/bcc\:/i",
"/cc\:/i",
"/Content\-Transfer\-Encoding\:/i",
"/Content\-Type\:/i",
"/Mime\-Version\:/i",'/(\n+)/i',
'/(\r+)/i',
'/(\t+)/i',
'/(%0A+)/i',
'/(%0D+)/i',
'/(%08+)/i',
'/(%09+)/i'
);
//Let's start our headers
$from_name = preg_replace($bad_headers, '', $_POST['from_name']);
$from_email = preg_replace($bad_headers, '', $_POST['from_email']);
$body = preg_replace($bad_headers, '', $_POST['body']);
//$headers = "From: $from_name<" . $from_name . ">\n";
$headers = "From: $from_name<" . $_POST['from_email'] . ">\n";
$headers .= "Reply-To: <" . $from_email . ">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n";
$headers .= "X-Sender: $from_name<" . $body . ">\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 3\n"; //1 = Urgent, 3 = Normal
$headers .= "Return-Path: <" . $body . ">\n";
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "------=MIME_BOUNDRY_main_message \n";
$headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";
$message = "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
/* Add our message, in this case it's plain text. You could also add HTML by changing the Content-Type to text/html */
$message .= "$body\n";
$message .= "\n";
$message .= "------=MIME_BOUNDRY_message_parts--\n";
$message .= "\n";
$message .= "------=MIME_BOUNDRY_main_message\n";
$message .= "Content-Type: application/octet-stream;\n\tname=\"" . $attachment_name . "\"\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: attachment;\n\tfilename=\"" . $attachment_name . "\"\n\n";
$message .= $data; //The base64 encoded message
$message .= "\n";
$message .= "------=MIME_BOUNDRY_main_message--\n";
// send the message
mail("$to_name<$to_email>", $subject, $message, $headers);
print "Mail sent. Thank you for using the MyNewName5333 Mailer.";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="XHTML namespace" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!--
body {
margin: 0px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
a {color: #0000ff}
-->
</style>
</head>
<body>
<?php
switch ($action) {
case "send":
sendMail();
showForm();
break;
default:
showForm();
}
?>
</body>
</html>