Advertisement
Guest User

Untitled

a guest
Jun 12th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <?php
  2.  
  3. // escape strings in input data
  4. $firstName = pg_escape_string($_POST['firstName']);
  5. $lastName = pg_escape_string($_POST['lastName']);
  6. $occupation = pg_escape_string($_POST['occupation']);
  7.  
  8. //$application = pg_escape_string($_POST['application']);
  9. $data = file_get_contents($_POST['application']);
  10. $escapeddata = pg_escape_bytea($dbh, $data);
  11.  
  12.  
  13. // open connection and execute query
  14. $db = pg_connect('host=localhost dbname=vhost63610p0 user=vhost63610p0 password=WebWarePostgreSQL');
  15. $query = "INSERT INTO applications (first_name, last_name, occupation, application) VALUES ('$firstName', '$lastName', '$occupation', '$application') RETURNING *";
  16. $result = pg_query($db, $query);
  17.  
  18. // fetch a row as an associative array and create a valid json object
  19. print json_encode(pg_fetch_assoc($result));
  20.  
  21. // close connection
  22. pg_close($dbh);
  23.  
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement