Code: Select all
<?php
// Receiving variables
$Name = addslashes($_POST['Name']);
$Email = addslashes($_POST['Email']);
$Tel = addslashes($_POST['Tel']);
$JobCV_Name = $_FILES['JobCV']['name'];
$JobCV_Size = $_FILES['JobCV']['size'];
$JobCV_Temp = $_FILES['JobCV']['tmp_name'];
$JobCV_Mime_Type = $_FILES['JobCV']['type'];
$Validation = 1;
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
// Validation
if (strlen($Name) == 0 )
{
echo "Your Must enter a name.<br>";
$Validation=0;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email))
{
echo "Your Must enter a valid email.<br>";
$Validation=0;
}
if (strlen($Email) == 0 )
{
echo "Your Must enter a email.<br>";
$Validation=0;
}
if ( $Tel <= 0)
{
echo "Your Must enter a valid telephone number .<br>";
$Validation=0;
}
if (strlen($Tel) == 0 )
{
echo "Your Must enter a telephone number.<br>";
$Validation=0;
}
if( $JobCV_Size == 0)
{
echo "Your Must upload a CV.<br>";
$Validation=0;
}
if( $JobCV_Size >35000000)
{
//delete file
unlink($JobCV_Temp);
echo "Your file was too large.<br>";
$Validation=0;
}
if( $JobCV_Mime_Type != "application/msword" )
{
unlink($JobCV_Temp);
echo "You can only upload a microsoft word document.<br>";
$Validation=0;
}
if ($Validation==0)
{
Echo "Sorry your file was not uploaded press back and try again";
}
else
{
$uploadFile = "Uploads/".$JobCV_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $JobCV_Temp , $uploadFile);
chmod($uploadFile, 0644);
$JobCV_URL = "http://www.........................co.uk/pages/Uploads/".$JobCV_Name ;
//Sending Email to form owner
$pfw_header = "From: $Email\n"
. "Reply-To: $Email\n";
$pfw_subject = "Job Application";
$pfw_email_to = "...@..........co.uk";
$pfw_message = "Name: $Name\n"
. "Email: $Email\n"
. "Tel: $Tel\n"
. "JobCV: $JobCV_URL\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
//Sending auto respond Email to visitor
$pfw_header = "From: ......@........co.uk\n"
. "Reply-To: .....@..........co.uk\n";
$pfw_subject = "Job Application";
$pfw_email_to = "$Email";
$pfw_message = "We receved your CV";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
//saving record in a text file
$pfw_file_name = "Jobs.csv";
$pfw_first_raw = "Name,Email,Tel,JobCV\r\n";
$pfw_values = "$Name,$Email,$Tel,$JobCV_Name\r\n";
$pfw_is_first_row = false;
if(!file_exists($pfw_file_name))
{
$pfw_is_first_row = true ;
}
if (!$pfw_handle = fopen($pfw_file_name, 'a+')) {
die("Cannot open file ($pfw_file_name)");
exit;
}
if ($pfw_is_first_row)
{
if (fwrite($pfw_handle, $pfw_first_raw ) === FALSE) {
die("Cannot write to file ($pfw_filename)");
exit;
}
}
if (fwrite($pfw_handle, $pfw_values) === FALSE) {
die("Cannot write to file ($pfw_filename)");
exit;
}
fclose($pfw_handle);
header("Location: ThankYouJobs.html");
}
?>
Code: Select all
if( $JobCV_Mime_Type != "application/msword" )
{
unlink($JobCV_Temp);
echo "You can only upload a microsoft word document.<br>";
$Validation=0;Code: Select all
<form action="jobs.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="483" border="0">
<tr>
<td width="66" align="right">Name:</td>
<td width="407"><label>
<input name="Name" type="text" id="Name" accesskey="1" tabindex="1" size="30" />
</label></td>
</tr>
<tr>
<td align="right">Email:</td>
<td><label>
<input name="Email" type="text" id="Email" accesskey="2" tabindex="2" size="30" />
</label></td>
</tr>
<tr>
<td align="right">Tel:</td>
<td><label>
<input name="Tel" type="text" id="Tel" accesskey="3" tabindex="3" size="30" />
</label></td>
</tr>
<tr>
<td align="right">CV:</td>
<td><label>
<input name="JobCV" type="file" id="JobCV" accesskey="4" tabindex="4" size="30" />
</label></td>
</tr>
<tr>
<td align="right"> </td>
<td><label>
<input name="Submit" type="submit" id="Submit" accesskey="5" tabindex="5" onclick="MM_validateForm('Name','','R','Email','','RisEmail','Tel','','RisNum');return document.MM_returnValue" value="send" />
</label>
<label>
<input type="reset" name="Reset" id="Reset" value="Clear" accesskey="6" tabindex="6" />
</label></td>
</tr>
</table>
</form>