Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class sabtmelk_model extends Model
- {
- function __construct()
- {
- parent::__construct();
- }
- function sabtmelk(){
- $amlak = new amlak();
- function loged_in(){
- $amlak = new amlak();
- if(isset($_SESSION['name'])){
- $name = $_SESSION['name'];
- $sql = "select * from `user` WHERE `name` = ?";
- $data = array($name);
- $res = $amlak->select($sql,$data);
- //print_r($res);
- if ($res > 1){
- return true;
- }else{
- return false;
- }
- }else{
- return false;
- }
- }
- //setcookie
- $cookie_name = name();
- $cookie_pass = pass();
- setcookie($cookie_name, $cookie_pass, time() + (60 * 20), "/");
- $error = "";
- $ok = "true";
- if(isset($_POST['shahr'])){
- $user = "";
- if (loged_in()){
- $user = $_SESSION['name'];
- }else{
- $user = $cookie_name;
- $pass = $cookie_pass;
- }
- $op1 = $_POST['op1'];
- if($op1 == "1"){
- if($_POST['shahr'] == "" || $_POST['ostan'] == "" || $_POST['edame_address'] == "" || $_POST['noe_melk'] == "" || $_POST['tedad_khab'] == "" || $_POST['tozih'] == "" || $_POST['gheymat_kharid'] == "" || $_POST['metraj'] == "" || $_POST['gheymat'] == "" || $_POST['tel'] == "" || $_POST['malek'] == ""){
- $error .= "فیلدهارو تکمیل نمایید"."<br>";
- $ok = "false";
- }//check empty
- $ostan = $_POST['ostan'];
- $shahr = $_POST['shahr'];
- $edame_address = $_POST['edame_address'];
- $noe_melk = $_POST['noe_melk'];
- $metraj = $_POST['metraj'];
- $tedad_khab = $_POST['tedad_khab'];
- $tozih = $_POST['tozih'];
- $gheymat_kharid = $_POST['gheymat_kharid'];
- $gheymat = $_POST['gheymat'];
- $ejare = $_POST['ejare'];
- $rahn = $_POST['rahn'];
- $malek = $_POST['malek'];
- $tel = $_POST['tel'];
- $user = $cookie_name;
- $pass = $cookie_pass;
- $sql = "INSERT INTO `add_melk` (`ostan` , `shahr` , `edame_address` , `noe_melk` , `metraj` , `tedad_khab` , `tozih` , `gheymat_kharid` , `gheymat` , `ejare` , `rahn` , `malek` , `tel` ,`name_user` , `pass_user`) VALUES (
- ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)";
- $data = array($ostan,$shahr,$edame_address,$noe_melk,$metraj,$tedad_khab,$tozih,$gheymat_kharid,$gheymat,$ejare,$ejare,$malek,$tel,$user,$pass);
- $res = $amlak->Idu($sql,$data);
- if($res == 1)
- {
- $error .= "ملک ثبت شد"."<br>";
- $ok = "true";
- }else{
- $error .= "خطا در ثبت ملک"."<br>";
- $ok = "false";
- }
- }else{
- if($_POST['shahr'] == "" || $_POST['ostan'] == "" || $_POST['edame_address'] == "" || $_POST['noe_melk'] == "" || $_POST['tedad_khab'] == "" || $_POST['tozih'] == "" || $_POST['gheymat_kharid'] == "" || $_POST['metraj'] == "" || $_POST['gheymat'] == "" || $_POST['tel'] == "" || $_POST['ejare'] == "" || $_POST['rahn'] == "" || $_POST['malek'] == "" || $_POST['tel'] == ""){
- $error .= "فیلدهارو تکمیل نمایید"."<br>";
- $ok = "false";
- }//check empty
- $ostan = $_POST['ostan'];
- $shahr = $_POST['shahr'];
- $edame_address = $_POST['edame_address'];
- $noe_melk = $_POST['noe_melk'];
- $metraj = $_POST['metraj'];
- $tedad_khab = $_POST['tedad_khab'];
- $tozih = $_POST['tozih'];
- $gheymat_kharid = $_POST['gheymat_kharid'];
- $gheymat = $_POST['gheymat'];
- $ejare = $_POST['ejare'];
- $rahn = $_POST['rahn'];
- $malek = $_POST['malek'];
- $tel = $_POST['tel'];
- $user = $cookie_name;
- $pass = $cookie_pass;
- $sql = "INSERT INTO `add_melk` (`ostan` , `shahr` , `edame_address` , `noe_melk` , `metraj` , `tedad_khab` , `tozih` , `gheymat_kharid` , `gheymat` , `ejare` , `rahn` , `malek` , `tel`, `name_user` , `pass_user`) VALUES (
- ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)";
- $data = array($ostan,$shahr,$edame_address,$noe_melk,$metraj,$tedad_khab,$tozih,$gheymat_kharid,$gheymat,$ejare,$ejare,$malek,$tel,$user,$pass);
- $res = $amlak->Idu($sql,$data);
- if($res == 1)
- {
- $error .= "ملک ثبت شد"."<br>";
- $ok = "true";
- }
- else
- {
- $error .= "خطا در ثبت ملک"."<br>";
- $ok = "false";
- }
- }
- }else{
- $error .= "خطا"."<br>";
- $ok = "false";
- }
- echo '{"ok":"'.$ok.'","message":"'.$error.'"}';
- exit;
- }//sabtmelk
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement