daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Dec 6th, 2016 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <?php
  3. ini_set("display_errors", 1);
  4. ini_set("display_startup_errors", 1);
  5. error_reporting(E_ALL);
  6. ?>
  7.  
  8. <html>
  9.     <head>
  10.         <title>Friends and Family</title>
  11.     </head>
  12.     <body>
  13. <?php
  14.  
  15. //    INSERT FUNCTION
  16. function insert($conn, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n)
  17.     {
  18.  
  19.     $query = "INSERT INTO people values('$a','$b','$c','$d','$e','$f',$g,'$h',$i,$j,'$k','$l','$m','$n',NULL)";
  20.     $result = $conn->query($query);
  21.     if (!$result)
  22.         die("Database access failed: " . $conn->error);
  23.     echo 'success!';
  24.     }
  25.  
  26. require_once 'login.php';
  27. $conn = new mysqli($hn, $un, $pw, $db);
  28. if ($conn->connect_error)
  29.     die($conn->connect_error);
  30.  
  31. //CREATE
  32. if (isset($_POST['create']))
  33.     {
  34.     $fname = $_POST['fname'];
  35.     $lname = $_POST['lname'];
  36.     $phone = $_POST['phone'];
  37.     $address = $_POST['address'];
  38.     $city = $_POST['city'];
  39.     $state = $_POST['state'];
  40.     $zip = $_POST['zip'];
  41.     $month = $_POST['month'];
  42.     $day = $_POST['day'];
  43.     $year = $_POST['year'];
  44.     $myusername = $_POST['myusername'];
  45.     $mypassword = $_POST['mypassword'];
  46.     $sex = $_POST['sex'];
  47.     $relation = $_POST['relation'];
  48.  
  49.     echo $fname . '<br>';
  50.     echo $lname . '<br>';
  51.     echo $phone . '<br>';
  52.     echo $address . '<br>';
  53.     echo $city . '<br>';
  54.     echo $state . '<br>';
  55.     echo $zip . '<br>';
  56.     echo $month . '<br>';
  57.     echo $day . '<br>';
  58.     echo $year . '<br>';
  59.     echo $myusername . '<br>';
  60.     echo $mypassword . '<br>';
  61.     echo $sex . '<br>';
  62.     echo $relation . '<br>';
  63.  
  64.     insert($conn, $fname, $lname, $phone, $address, $city, $state, $zip, $month, $day, $year, $myusername, $mypassword, $sex, $relation);
  65.     }
  66.  
  67.  
  68. //SEARCH
  69. if (isset($_POST['search']))
  70.     {
  71.     if (isset($_POST['fname']))
  72.         {
  73.         $fname = $_POST['fname'];
  74.         $query = "SELECT first_name, last_name, phone_number, address, city, state, zip, birth_month, birth_day, birth_year, username, password, sex, relationship, id from people where first_name = '$fname'";
  75.         $result = $conn->query($query);
  76.  
  77.         $rows = $result->num_rows;
  78.         for ($j = 0; $j < $rows; ++$j)
  79.             {
  80.             $result->data_seek($j);
  81.             $row = $result->fetch_array(MYSQLI_NUM);
  82.  
  83.             echo <<<_END
  84. <pre>
  85. First Name: $row[0]
  86. Last Name: $row[1]
  87. Phone Number $row[2]
  88. Address $row[3]
  89. City $row[4]
  90. State $row[5]
  91. State $row[5]
  92. Zip $row[6]
  93. Birth month $row[7]
  94. Birth Day $row[8]
  95. Birth Year $row[9]
  96. Username $row[10]
  97. Password $row[11]
  98. Sex $row[12]
  99. Relationship $row[13]
  100. ID $row[14]
  101. </pre>
  102. _END;
  103.             if (!$result)
  104.                 die("Database access failed: " . $conn->error);
  105.             echo 'success!';
  106.             }
  107.         }
  108.  
  109.     if (isset($_POST['lname']))
  110.         {
  111.         $lname = $_POST['lname'];
  112.         $query = "SELECT first_name, last_name, phone_number, address, city, state, zip, birth_month, birth_day, birth_year, username, password, sex, relationship, id from people where last_name = '$lname'";
  113.         $result = $conn->query($query);
  114.  
  115.         $rows = $result->num_rows;
  116.         for ($j = 0; $j < $rows; ++$j)
  117.             {
  118.             $result->data_seek($j);
  119.             $row = $result->fetch_array(MYSQLI_NUM);
  120.  
  121.             echo <<<_END
  122. <pre>
  123. First Name: $row[0]
  124. Last Name: $row[1]
  125. Phone Number $row[2]
  126. Address $row[3]
  127. City $row[4]
  128. State $row[5]
  129. State $row[5]
  130. Zip $row[6]
  131. Birth month $row[7]
  132. Birth Day $row[8]
  133. Birth Year $row[9]
  134. Username $row[10]
  135. Password $row[11]
  136. Sex $row[12]
  137. Relationship $row[13]
  138. ID $row[14]
  139. </pre>
  140. _END;
  141.  
  142.  
  143.             if (!$result)
  144.                 die("Database access failed: " . $conn->error);
  145.             echo 'success!';
  146.             }
  147.         }
  148.     }
  149.  
  150.  
  151. //   UPDATE
  152. if (isset($_POST['update']))
  153.     {
  154.     $username = $_POST['myusername'];
  155.     $run_the_query = FALSE;
  156.  
  157.     $fname = $_POST['fname'];
  158.     $lname = $_POST['lname'];
  159.     $phone = $_POST['phone'];
  160.     $address = $_POST['address'];
  161.     $city = $_POST['city'];
  162.     $state = $_POST['state'];
  163.     $zip = $_POST['zip'];
  164.     $month = $_POST['month'];
  165.     $day = $_POST['day'];
  166.     $year = $_POST['year'];
  167.     $myusername = $_POST['myusername'];
  168.     $mypassword = $_POST['mypassword'];
  169.     $sex = $_POST['sex'];
  170.     $relation = $_POST['relation'];
  171.  
  172.     $my_string = "UPDATE people SET first_name = '$fname', last_name = '$lname', phone_number = '$phone', address = '$address', city = '$city', state = '$state', zip = '$zip', birth_month = '$month', birth_day = '$day', birth_year = '$year', password = '$mypassword', sex = '$sex', relationship = '$relation' WHERE username = '$username'";
  173.     $result = $conn->query($my_string);
  174.     }
  175. ?>
  176.     </body>
  177. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top