I have written the code to store the form info … to mysql database … so m getting error as unexpected variable . please help me .
<?php
function control($val,$min,$max,$ctype,$check)
{
if($check == ‘Y’)
{
// no spaces are allowed //
$secure = strip_tags(stripslashes(str_replace(’ ‘,’',(htmlentities($val)))));
}
else
{
// spaces are allowed //
$secure = strip_tags(stripslashes(trim(htmlentities($val))));
}
if($secure == '')
{
echo "Enter ".$ctype;
exit();
}
else if(strlen($secure) < $min)
{
echo "Enter Minimum ".$min." Characters ".$ctype;
exit();
}
else if(strlen($secure) > $max)
{
echo "Enter Maximum ".$max." Characters ".$ctype;
exit();
}
return $secure;
}
function userdata()
{
if(isset($_POST[‘btnSub2’]))
{
$job_name=control($_POST[‘jobname’],2,100,‘Job Applying For’,‘N’);
$gender=control($_POST[‘gender’],1,1,‘Gender’,‘Y’);
$first_name=control($_POST[‘firstname’],1,30,‘First Name’,‘N’);
$last_name=control($_POST[‘lastname’],1,30,‘Last Name’,‘N’);
$city=control($_POST[‘strcity’],2,50,‘City’,‘N’);
$state=control($_POST[‘strstate’],2,50,‘State’,‘N’);
$country=control($_POST[‘country’],2,50,‘Country’,‘N’);
$phone_mobile=control($_POST[‘strno’],8,15,‘Phone’,‘Y’);
$email=control($_POST[‘fromemail’],5,60,‘Email Address’,‘Y’);
$experience=control($_POST[‘totalexp’],1,2,‘Experience’,‘Y’);
$comment=control($_POST[‘strcomments’],10,500,‘Comment’,‘N’);
$file_name = str_replace('_','',$_FILES['filename']['name']);
$file_error = $_FILES['filename']['error'];
if(!is_numeric($strno))
{
echo "Phone/Mobile Should be Numeric";
}
else
(
$upload = false;
$explode_file = explode('.',$file_name)
$extension_supplied = $explode_file[count($explode_file) - 1];
$extension_allowed = array('doc','docx');
for($check=0; $check<count($extension_allowed); $check++)
{
if($extension_supplied == $extension_allowed[$check])
{
$upload = true;
}
}
// current timestamp //
$timestamp = time();
// temporary file name //
$tmp_file_name = strtolower($fname)."_".strtolower($lname)."_".$timestamp."_".$file_name;
// target directory //
$target = "resume_coll/".$tmp_file_name;
if($upload == true)
{
// connecting to database server //
mysql_connect('db.domain.net','dbo3','glo');
mysql_select_db('db1234566');
$sql = "select email from tbl_user_details where email='$email'";
if(mysql_num_rows(mysql_query($sql)) == 0)
{
$sql = "select phone_mobile from tbl_user_details where phone_mobile='$phone'";
if(mysql_num_rows(mysql_query($sql)) == 0)
{
$sql = "insert into tbl_user_details values('','$job','$gender','$fname','$lname','$city','$state','$country',$phone,'$email',$experience,'$comment','$tmp_file_name',now())";
if(mysql_query($sql))
{
if(is_uploaded_file($_FILES['filename']['tmp_name']))
{
if(move_uploaded_file($_FILES['filename']['tmp_name'],$target))
{
$message ="
<table>
<tr><th colspan=3 style='text-align:left;'>User Details</th></tr>
<tr><td>First Name</td><td>:</td><td>$fname</td></tr>
<tr><td>Last Name</td><td>:</td><td>$lname</td></tr>
<tr><td>City</td><td>:</td><td>$city</td></tr>
<tr><td>State</td><td>:</td><td>$state</td></tr>
<tr><td>Country</td><td>:</td><td>$country</td></tr>
<tr><td>Phone/Mobile</td><td>:</td><td>$phone</td></tr>
<tr><td>Email</td><td>:</td><td>$email</td></tr>
<tr><td>Experience</td><td>:</td><td>$experience Year(s)</td></tr>
<tr><td>Comment</td><td>:</td><td>$comment</td></tr>
<tr><td>Resume</td><td>:</td><td><a href=http://mydomain.com/resume_coll/$tmp_file_name>Download Now</a></td></tr>
</table>";
$receiver = 'mydomain.com';
$subject = "Resume Uploaded by ".ucwords($fname)." ".ucwords($lname);
echo "in resume upload";
$headers = "From:".$email."\\r\
“.“Reply-To:”.$email.”\r
";
$headers .= "Content-type: text/html\r
";
//$message = htmlentities($message);
$mail = mail($receiver,$subject,$message,$headers);
if($mail)
{
echo "You will receive a confirmation E-mail with User Name and Password information ";
}
else
{
echo “Internet Connection Problem”;
}
}
else
{
echo “Resume not Transfer to Server”;
}
}
else
{
echo “Resume is not Uploaded.”;
}
}
}
else
{
echo “This Phone/Mobile is Already Existed”;
}
}
else
{
echo “This Email Already Uploaded Resume”;
}
}
else
{
echo “Invalid File Extension (<b>$extension_supplied</b>) to Upload.”;
}
}
}
}
function execute_code()
{
return userdata();
}
echo execute_code();
?>