Advertisement
Guest User

Untitled

a guest
May 26th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. // SERVER VARIABLES
  2.  
  3. // include.php
  4.  
  5. <?php
  6.  
  7. $server = "server name e.g. localhost"
  8. $database = "database name"
  9. $db_user = "database username"
  10. $db_pass = "database password"
  11. $table = "database table to connect to"
  12.  
  13. ?>
  14.  
  15. // OPENING DATABASE
  16.  
  17. // opendb.php
  18.  
  19. <?php
  20.  
  21. $link = mysql_connect($server, $db_user, $db_pass)
  22. or die ("Could not connect to database because ".mysql_error());
  23.  
  24. mysql_select_db($database)
  25. or die ("Could not select database because ".mysql_error());
  26.  
  27. ?>
  28.  
  29. // COLLECTING DATA
  30.  
  31. // collect.php
  32.  
  33. <?php
  34.  
  35. SESSION_START();
  36.  
  37. include("include.php");
  38. include("opendb.php");
  39.  
  40. $query_find_details = "SELECT * FROM table WHERE tablerow \"". $_SESSION ['data to store']."\"";
  41. $result_find_details = mysql_query($query_find_details);
  42. $count_find_details = mysql_num_rows($result_find_details);
  43. $row_find_details = mysql_fetch_array($result_find_details);
  44.  
  45. ?>
  46.  
  47. // INSERTING DATA INTO THE DATABASE
  48.  
  49. <?php
  50.  
  51. SESSION_START();
  52.  
  53. include("include.php");
  54. include("opendb");
  55.  
  56. $insert = mysql_query("insert into $table values ('NULL', '".$_POST['column name']."' , '".$_POST['column name']."' , '".md5($_POST['password']."')")
  57. or die ("Could not insert data because ".mysql_error());
  58.  
  59. ?>
  60.  
  61. // ECHOING DATA FROM DATABASE
  62.  
  63. <?php
  64.  
  65. include("collect.php");
  66.  
  67. echo "".$row_find_details['name']." <br> ".$row_find_details['name']." <br> ".$row_find_details['name'].";
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement