Pegi opis KJ (Kelana Jaya ok) present company website to CEO... almaklum le orang penting huhu (sebenarnye x pun.. cume ganti bos.. sebab bos ade hal lagi penting dari setakat nak present website ni...)
Dan2 lepas present... CEO request pada bahagian senarai keje kosong tu.. nak buat canggih sikit... supaya sape2 yang tgk iklan kat website boleh terus upload resume dari website to jugak.. and terus terbang resume tu ke email HR...
Hu hu hu.......
Otak dok pikir.............
Macam kena ..... Buat database + relate dengan form + pastu ?????? macam mane nak attach kat email lak???
Eeee macam susah je.... tapi mulut ni gatal cakap kat CEO "BOLEH BOS!!!".... kepala lak ringan je ANGGUK ANGGUK.... (Macam terrorrrrr lah sangatttt aku ni!!!)
Balik umah dah termenung....... Dok kat toilet pun termenung.....
HARI NI:
Masuk opis temenung depan mr.lappy and otak jalan mcm enjin kete camry.... (camry lah sangat!!! haha..)
TRY & ERROR is the best experience (love this way... masuk otak melekat tak keluar2..)
Ok... macam mane nak buat uploas file resume kat website and bila send terus masuk attachment tu kat email orang?...
Begini cara nye... ting ting ting.....
1st STEP:
You guys kena copy paste coding kat bawah ni.. and save kan file ni dengan nama career.php
<html>
<head>
<title>PHP ERNI MAT</title>
</head>
<body>
<form action="php_sendmail_upload.php" method="post" name="form1" enctype="multipart/form-data">
<table width="100%">
<tr>
<td colspan="2" bgcolor="#EEEEEE" class="style7"><div align="center">
<p><br />
Minat nak keje? Jom upload resume korang kat borang ni ;D <span class="style27"><span class="style27"><br />
<br />
</span></span></p>
</div></td>
</tr>
<tr>
<td bgcolor="#EEEEEE"><div align="center"><span class="style27">Your Full Name </span></div></td>
<td bgcolor="#EEEEEE"><input name="txtFormName" type="text" size="50" /></td>
</tr>
<tr>
<td width="26%" bgcolor="#EEEEEE"><div align="center"><span class="style27">Desired Job Tittle </span></div></td>
<td width="74%" bgcolor="#EEEEEE"><input name="txtDescription" type="text" id="txtDescription" size="50" /> </td>
</tr><tr>
<td bgcolor="#EEEEEE"><div align="center"><span class="style27">Your Email</span></div></td>
<td bgcolor="#EEEEEE"><input name="txtFormEmail" type="text" size="50" /></td>
</tr>
<tr>
<td bgcolor="#EEEEEE"><div align="center"><span class="style27">Attach Resume </span></div></td>
<td bgcolor="#EEEEEE"><input name="fileAttach" type="file"></td>
</tr>
<tr>
<td bgcolor="#EEEEEE"> </td>
<td bgcolor="#EEEEEE"><input type="submit" name="Submit" value=":: SEND TO US ::" /></td>
</tr>
</table>
</form>
</body>
</html>
2nd STEP:
Bukak file baru... pastu copy paste coding kat bawah ni.. lepas tu save nama file tu sebagai php_sendmail_upload.php
<html>
<head>
<title>PHP ERNI MAT</title>
</head>
<body>
<?
$strTo = 'tukarEmailPenerima@emailApeje.com';
$strSubject = 'Resume '.$_POST["txtFormName"];
$strMessage = nl2br($_POST["txtDescription"]);
//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));
$strHeader = "";
$strHeader .= "From: ".$_POST["txtFormName"]."<".$_POST["txtFormEmail"].">\nReply-To: ".$_POST["txtFormEmail"]."";
$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-type: text/html; charset=utf-8\n";
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $strMessage."\n\n";
//*** Attachment ***//
if($_FILES["fileAttach"]["name"] != "")
{
$strFilesName = $_FILES["fileAttach"]["name"];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
$strHeader .= $strContent."\n\n";
}
$flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "Mail send completed.";
}
else
{
echo "Cannot send mail.";
}
?>
</body>
</html>
Pastu letak kedua dua file ni dalam folder yang same.... and run kan si file bernama career.php tadi... you guys akan dapat satu borang berbentuk macam kat bawah ni....
Tadaaaaaaaa.....!!!!
Akhirnye berjaya jugak merialisasikan impian CEO nak ade borang upload ni kat website...
Senang je rupenye wat borang online gune PHP.. pastu automaik attach file yang kita upload tu ke email penerima...
Paling terkesima sekejap... TAKYAH SUSAH2 PAKAI DATABASE!!!... hohoho...
Walaupun sesetengah programmer cakap benda ni senang je...
Tapi tak semua programmer tau ye tak???
So sharing is caring!!
Hope u guys try kalau ade bos2 korang mintak benda2 macam ni dalam website....
Tataaaa..!!!!!
0 comments:
Post a Comment