Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.29 KB | None | 0 0
  1. class sabtmelk_model extends Model
  2. {
  3. function __construct()
  4. {
  5.  
  6. parent::__construct();
  7. }
  8.  
  9. function sabtmelk(){
  10.  
  11.  
  12. $amlak = new amlak();
  13.  
  14.  
  15. function loged_in(){
  16. $amlak = new amlak();
  17. if(isset($_SESSION['name'])){
  18. $name = $_SESSION['name'];
  19. $sql = "select * from `user` WHERE `name` = ?";
  20. $data = array($name);
  21. $res = $amlak->select($sql,$data);
  22. //print_r($res);
  23. if ($res > 1){
  24. return true;
  25. }else{
  26. return false;
  27. }
  28. }else{
  29. return false;
  30. }
  31. }
  32.  
  33. //setcookie
  34. $cookie_name = name();
  35. $cookie_pass = pass();
  36. setcookie($cookie_name, $cookie_pass, time() + (60 * 20), "/");
  37.  
  38.  
  39. $error = "";
  40. $ok = "true";
  41. if(isset($_POST['shahr'])){
  42.  
  43.  
  44.  
  45. $user = "";
  46. if (loged_in()){
  47.  
  48. $user = $_SESSION['name'];
  49.  
  50. }else{
  51. $user = $cookie_name;
  52. $pass = $cookie_pass;
  53. }
  54.  
  55.  
  56.  
  57. $op1 = $_POST['op1'];
  58. if($op1 == "1"){
  59.  
  60. 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'] == ""){
  61.  
  62. $error .= "فیلدهارو تکمیل نمایید"."<br>";
  63. $ok = "false";
  64.  
  65. }//check empty
  66.  
  67.  
  68.  
  69. $ostan = $_POST['ostan'];
  70. $shahr = $_POST['shahr'];
  71. $edame_address = $_POST['edame_address'];
  72. $noe_melk = $_POST['noe_melk'];
  73. $metraj = $_POST['metraj'];
  74. $tedad_khab = $_POST['tedad_khab'];
  75. $tozih = $_POST['tozih'];
  76. $gheymat_kharid = $_POST['gheymat_kharid'];
  77. $gheymat = $_POST['gheymat'];
  78. $ejare = $_POST['ejare'];
  79. $rahn = $_POST['rahn'];
  80. $malek = $_POST['malek'];
  81. $tel = $_POST['tel'];
  82. $user = $cookie_name;
  83. $pass = $cookie_pass;
  84.  
  85.  
  86. $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 (
  87. ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)";
  88. $data = array($ostan,$shahr,$edame_address,$noe_melk,$metraj,$tedad_khab,$tozih,$gheymat_kharid,$gheymat,$ejare,$ejare,$malek,$tel,$user,$pass);
  89. $res = $amlak->Idu($sql,$data);
  90.  
  91. if($res == 1)
  92. {
  93. $error .= "ملک ثبت شد"."<br>";
  94. $ok = "true";
  95. }else{
  96. $error .= "خطا در ثبت ملک"."<br>";
  97. $ok = "false";
  98. }
  99.  
  100. }else{
  101.  
  102. 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'] == ""){
  103.  
  104. $error .= "فیلدهارو تکمیل نمایید"."<br>";
  105. $ok = "false";
  106.  
  107. }//check empty
  108.  
  109. $ostan = $_POST['ostan'];
  110. $shahr = $_POST['shahr'];
  111. $edame_address = $_POST['edame_address'];
  112. $noe_melk = $_POST['noe_melk'];
  113. $metraj = $_POST['metraj'];
  114. $tedad_khab = $_POST['tedad_khab'];
  115. $tozih = $_POST['tozih'];
  116. $gheymat_kharid = $_POST['gheymat_kharid'];
  117. $gheymat = $_POST['gheymat'];
  118. $ejare = $_POST['ejare'];
  119. $rahn = $_POST['rahn'];
  120. $malek = $_POST['malek'];
  121. $tel = $_POST['tel'];
  122. $user = $cookie_name;
  123. $pass = $cookie_pass;
  124.  
  125. $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 (
  126. ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)";
  127. $data = array($ostan,$shahr,$edame_address,$noe_melk,$metraj,$tedad_khab,$tozih,$gheymat_kharid,$gheymat,$ejare,$ejare,$malek,$tel,$user,$pass);
  128. $res = $amlak->Idu($sql,$data);
  129.  
  130. if($res == 1)
  131. {
  132. $error .= "ملک ثبت شد"."<br>";
  133. $ok = "true";
  134. }
  135. else
  136. {
  137. $error .= "خطا در ثبت ملک"."<br>";
  138. $ok = "false";
  139. }
  140.  
  141.  
  142.  
  143.  
  144. }
  145.  
  146.  
  147.  
  148.  
  149.  
  150. }else{
  151. $error .= "خطا"."<br>";
  152. $ok = "false";
  153. }
  154.  
  155. echo '{"ok":"'.$ok.'","message":"'.$error.'"}';
  156. exit;
  157.  
  158.  
  159.  
  160.  
  161. }//sabtmelk
  162.  
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement