}
?>
#--------------------------------------------------
# filename - mysqlifunction.php
# Date - 14/12/2007
# Purpose - sql functions here
#--------------------------------------------------
CLASS SQL_FUNC_TION
{
#this function is used to connect server and database
function connect_db($dbname,$username,$pass,$server)
{
//echo $server." ";
//echo $username." ";
//echo $pass." ";
$connect_return = mysqli_connect("$server","$username","$pass");
if( $connect_return ){
mysqli_select_db($connect_return,$dbname);
}
else{
die("Could not connect: " . mysqli_error());
}
return $connect_return;
//echo "Connect Return"." "."$connect_return"." ";
}#end function connect_db
function connect_to_db()
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
}#end function connect_to_db
#this function is used to execute sql query
function query_db($conn,$qstring)
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
Global $ms_error;
$res = mysqli_query($conn,$qstring) or die(mysqli_error()."error111");
//echo "RES".$res;
return $res;
}#end function query_db
function result_db1($re,$row,$field)
{
$row1 = count($field);
for($i=0;$i<$row;$i++)
{
for($j=0;$j<$row1;$j++)
{
$result[] = mysqli_result($re,"$i","$field[$j]");
}
}
return $result;
}
#this function is used to get number of rows from the result set
function row_db($rvalue)
{
if($rvalue != "")
{
//echo "$rvalue"." ";
$row = mysqli_num_rows($rvalue);
return $row;
}
else
{
return 0;
}
}#end function row_db
#this function is used to insert record in db
function insertid_db()
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
$id = mysqli_insert_id();
//echo " ".$id." ";
//$this->close_db();
return $id;
}# end function insertid_db
#this function is used to get error number
function errno_db()
{
$errno = mysqli_errno();
return $errno;
}#end function errno_db
#this function is used to return sql errors
function err_db()
{
//echo mysqli_error();
return mysqli_error();
}#end function err_db
#this function is used to get affected rows
function aff_row()
{
$affrow = mysqli_affected_rows();
return $affrow;
}#end function aff_row
#this function is used to get the result in array
function result_db($re)
{
$Number_Of_Rows = $this->return_Number_Of_Rows($re);
$count=0;
# To populate the first row as array of Names of the fields in table
$rows_as_array[$count] = $this->return_Names_Of_Fields_As_Array($re);
# Start from populating the array with array from the 2nd row.
for ($count = 1; $count < $Number_Of_Rows+1; $count++)
{
$rows_as_array[$count]= mysqli_fetch_object ($re);
}
return $rows_as_array;
}#end function result_db
#this function is used to disconnect database
function close_db()
{
//mysqli_close();
}#end function close_db
#this function is used to get number of fields retrieved in result set
function return_Number_Of_Fields($result_identifier)
{
$Number_Of_Fields = @mysqli_num_fields($result_identifier);
return $Number_Of_Fields;
}# end function return_Number_Of_Fields
#this function is used to get number of rows from result set
function return_Number_Of_Rows($result_identifier)
{
$Number_Of_Rows = @mysqli_num_rows($result_identifier);
return $Number_Of_Rows;
}# end function return_Number_Of_Rows
#this function is used to get field name in array
function return_Names_Of_Fields_As_Array($result_identifier)
{
$no = $this->return_Number_Of_Fields($result_identifier);
for ($count = 0; $count < $no; $count++)
{
$field_name=mysqli_field_name($result_identifier,$count);
$test=$Names_Of_Fields[$field_name] =$field_name;
}
$no = $this->return_Number_Of_Rows($result_identifier);
return $Names_Of_Fields;
}# end of return_Name_Of_Fields_As_Array
#this function is used to call function to get result
function get_result($sql_query)
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
$sql_result=$this->query_db($sql_query);
$sql_resultarray=$this->result_db($sql_result);
return $sql_resultarray;
//$this->close_db();
}# end of get_result
#this function is used to call function to delete record
function del_record($conn,$tablename,$id_name,$id)
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
$sql_query="DELETE FROM ".$tablename." WHERE ".$id_name." =".$id." LIMIT 1";
$sql_result=$this->query_db($conn,$sql_query);
//$this->close_db();
return $sql_result;
}# end of get_result
# function to insert record
function insertrecord($conn,$tablename,$array)
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
$counttimer=1;
$tablefields="";
$formfield="";
foreach ($array as $key => $val)
{
$tablefields .= $key;
$formfield .= "\"".addslashes($val)."\"";
if(count($array)!=$counttimer)
{
$tablefields .=",";
$formfield .= ",";
}
$counttimer=$counttimer+1;
}
$sql = "insert into ".$tablename."(".$tablefields.") values (".$formfield.")";
$res=$this->query_db($conn,$sql);
$this->close_db();
return $res;
}
# function to update record
function updaterecord($conn,$tablename,$array,$where)
{
$update_fields="";
$counttimer=1;
foreach ($array as $key => $val)
{
$update_fields .=$key ."= \"" . addslashes($val)."\"";
if(count($array)!=$counttimer)
{
$update_fields .=",";
}
$counttimer=$counttimer+1;
}
$counttimer=1;
if($where!="")
{
$where_string ="";
foreach ($where as $key => $val)
{
$where_string .=$key ."= '" . $val."'";
if(count($where)!=$counttimer)
{
$where_string .=" and ";
}
$counttimer=$counttimer+1;
}
}
$sql = "update ".$tablename." set ".$update_fields;
if($where!="")
{
$sql.=" where ".$where_string;
}
$res=$this->query_db($conn,$sql);
//echo "
".$sql."
";
return $res;
}
#end of updaterecord function
}#end of class SQL_FUNCTION
?>
Click on map to search for hunting property
include("index1.php");
//print_r($_POST);
if(isset($_POST['submit'])){
if(isset($_POST['g-recaptcha-response'])) {
// RECAPTCHA SETTINGS
$captcha = $_POST['g-recaptcha-response'];
$ip = $_SERVER['REMOTE_ADDR'];
$key = '6Lf_oVocAAAAAKzoR9MdnthJYReBRcgyTLpeF48f';
$url = 'https://www.google.com/recaptcha/api/siteverify';
// RECAPTCH RESPONSE
$recaptcha_response = file_get_contents($url.'?secret='.$key.'&response='.$captcha.'&remoteip='.$ip);
$data = json_decode($recaptcha_response);
if(isset($data->success) && $data->success === true) {
$to = "riedelfarms@yahoo.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone_no=$_POST['phone_no'];
$message=$_POST['message'];
$subject = "Hunter Enquiry From Riedel Farm LLC";
/*$subject2 = "NAME : " .$fname." ".$lname." ".
"Phone Number : ".$phone_no." ".
"Property Address : " .$property_address." ".
"Property Description : " .$property_description." Plesae check above informarion given by you.";*/
$message = "Dear Riedel Farms Staff,\n\n
I am hunter and my information is as below,\n\n".
"Name : " .$fname." ".$lname."\n\n".
"Email id : ".$from."\n\n".
"Phone Number : ".$phone_no."\n\n".
"Message : " .$message."\n\nProerty details : \n\n".
"Property Title : " .$_POST['property_title']." \n\n ".
"Property Plot Number : " .$_POST['property_no_plot']." \n\n Thank you.";
// $message2 = "Here is a copy of your message " . $fname . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
// $headers2 = "From:" . $to;
$mail=mail($to,$subject,$message,$headers);
if($mail){
$msg="Mail Sent. Thank you " . $fname . ", we will contact you shortly.";
} else {
$msg=print_r(error_get_last());
}
}
else {
$captcha_msg="Please verify that you are not a robot.";
$msg="Please verify that you are not a robot.";
}
}
// mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
if(isset($_GET['property_id']) || isset($_POST['submit']) )
{
if(isset($_GET['property_id']))
{
$property_id=$_GET['property_id'];
}
else
{
$property_id=$_POST['property_id'];
}
$conn =mysqli_connect($hostname, $username, $pass);
mysqli_select_db($conn,$dbname);
$property_sql = 'select * from property where property_id='.$property_id;
$property_rs = mysqli_query($conn,$property_sql) or die(mysqli_error()."error111");
$property_row = mysqli_fetch_assoc($property_rs);
$photo_sql = 'select * from photo where property_id='.$property_id;
$photo_rs = mysqli_query($conn,$photo_sql) or die(mysqli_error()."**error111");
$county_sql = 'select * from county where county_id='.$property_row['property_county'];
$county_rs = mysqli_query($conn,$county_sql) or die(mysqli_error()."error111");
$county = mysqli_fetch_array($county_rs);
if($property_row['property_status']==1)
{
$status="AVAILABLE";
$buttoncolor="green";
}
else
{
$status="LEASED";
$buttoncolor="brown";
}
?>