Advertisement
Guest User

Untitled

a guest
May 10th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if(!$_SESSION['USER_NAME']) {
  4. echo "Need to login";
  5. }
  6. else {
  7. $Host= '192.168.1.8';
  8. $Dbname= 'app';
  9. $User= 'yyy';
  10. $Password= 'xxx';
  11. $Schema = 'test';
  12. $Conection_string="host=$Host dbname=$Dbname user=$User password=$Password";
  13. $Connect=pg_connect($Conection_string,$PGSQL_CONNECT_FORCE_NEW);
  14. if($_SERVER['REQUEST_METHOD'] == "POST") {
  15. $query="update $Schema.members set display_name='".$_POST['disp_name']."' where user_name='".$_SESSION['USER_NAME']."';";
  16. pg_query($Connect,$query);
  17. echo "Update Success";
  18. }
  19. else {
  20. if(strcmp($_SESSION['USER_NAME'],'admin')==0) {
  21. echo "Welcome admin<br><hr>";
  22. echo "List of user's are<br>";
  23. $query = "select display_name from $Schema.members where user_name!='admin'";
  24. $res = pg_query($Connect,$query);
  25. while($row=pg_fetch_array($res,NULL,PGSQL_ASSOC)) {
  26. echo "$row[display_name]<br>";
  27. }
  28. }
  29. else {
  30. echo "<form name=\"tgs\" id=\"tgs\" method=\"post\" action=\"home.php\">";
  31. echo "Update display name:<input type=\"text\" id=\"disp_name\" name=\"disp_name\" value=\"\">";
  32. echo "<input type=\"submit\" value=\"Update\">";
  33. }
  34. }
  35. }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement