Guest User

Untitled

a guest
Feb 9th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1.   <?php
  2.  
  3.     $host = '127.0.0.1';
  4.     $port = '5432';
  5.     $database = 'aaa';
  6.     $user = 'postgres';
  7.     $password = 'admin1234';
  8.    
  9.     $connectString = 'host=' . $host . ' port=' . $port . ' dbname=' . $database . ' user=' . $user . ' password=' . $password;
  10.     $link = pg_connect ($connectString);
  11.     if (!$link) {
  12.         die('Error: Could not connect: ' . pg_last_error());
  13.     }
  14.  
  15.  
  16.     if(isset($_POST['source'])) {
  17.     //var_dump($_POST['source']);
  18.         foreach($_POST['source'] as $value){
  19.             // $val = serialize($value);
  20.             var_dump($value);
  21.             $insert = "INSERT INTO source_of_fund_value(source_of_fund_1) VALUES ('". $value ."')";
  22.             pg_query($insert);
  23.         }
  24.     }
  25.     ?>
  26.    <html>
  27.    <body>
  28.    <form method="post" action="">
  29.    <input type="checkbox" name="source[]" value="salary">Salary
  30.   <input type="checkbox" name="source[]" value="inheritance"> Inheritance
  31.   <input type="checkbox" name="source[]" value="pension_fund"> Pension Fund
  32.   <input type="checkbox" name="source[]" value="others"> Others
  33.  
  34.    <input type="submit" name="submit" value="submit">
  35.    </form>
  36.   </body>
  37.  </html>
Add Comment
Please, Sign In to add comment