Instagram Status Post

In this tutorial we will create a instagram status script post in PHP and Javascript. This project creates a post message that you can comment or reply in every statuses that the user posted. And their are features that you will like delete post or you can comment to the other people post and it is real time process of the data so the user will know what day and what time did the user posted or created the status. This project is related to all SNS system that creates and shows the data to other user of that system. I will show you the sample code and images below.

Sample Code

Database PHP Script
  1. <?php
  2. require_once(LIB_PATH.DS."config.php");
  3. class Database {
  4. var $data;
  5. var $sql_string = '';
  6. var $error_no = 0;
  7. var $error_msg = '';
  8. private $conn;
  9. public $last_query;
  10. private $magic_quotes_active;
  11. private $real_escape_string_exists;
  12.  
  13. function __construct() {
  14. $this->open_connection();
  15. $this->magic_quotes_active = get_magic_quotes_gpc();
  16. $this->real_escape_string_exists = function_exists("mysql_real_escape_string");
  17. }
  18. public function open_connection() {
  19. $this->conn = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
  20. if(!$this->conn){
  21. echo "Problem in database connection! Contact administrator!";
  22. exit();
  23. }else{
  24. $db_select = mysql_select_db(DB_NAME,$this->conn);
  25. if (!$db_select) {
  26. echo "Problem in selecting database! Contact administrator!";
  27. exit();
  28. }
  29. }
  30. }
  31. function setQuery($sql='') {
  32. $this->sql_string=$sql;
  33. }
  34. function executeQuery() {
  35. $result = mysql_query($this->sql_string, $this->conn);
  36. $this->confirm_query($result);
  37. return $result;
  38. }
  39. private function confirm_query($result) {
  40. if(!$result){
  41. $this->error_no = mysql_errno( $this->conn );
  42. $this->error_msg = mysql_error( $this->conn );
  43. return false;
  44. }
  45. return $result;
  46. }
  47. function loadResultList( $key='' ) {
  48. $cur = $this->executeQuery();
  49. $array = array();
  50. while ($row = mysql_fetch_object( $cur )) {
  51. if ($key) {
  52. $array[$row->$key] = $row;
  53. } else {
  54. $array[] = $row;
  55. }
  56. }
  57. return $array;
  58. }
  59. function loadSingleResult() {
  60. $cur = $this->executeQuery();
  61. while ($row = mysql_fetch_object( $cur )) {
  62. return $data = $row;
  63. }
  64. }
  65. function getFieldsOnOneTable( $tbl_name ) {
  66. $this->setQuery("DESC ".$tbl_name);
  67. $rows = $this->loadResultList();
  68. $f = array();
  69. for ( $x=0; $x<count( $rows ); $x++ ) {
  70. $f[] = $rows[$x]->Field;
  71. }
  72. return $f;
  73. }
  74. public function fetch_array($result) {
  75. return mysql_fetch_array($result);
  76. }
  77. public function num_rows($result_set) {
  78. return mysql_num_rows($result_set);
  79. }
  80. public function insert_id() {
  81. return mysql_insert_id($this->conn);
  82. }
  83. public function affected_rows() {
  84. return mysql_affected_rows($this->conn);
  85. }
  86. public function escape_value( $value ) {
  87. if( $this->real_escape_string_exists ) {
  88. if( $this->magic_quotes_active ) { $value = stripslashes( $value ); }
  89. $value = mysql_real_escape_string( $value );
  90. } else {
  91. if( !$this->magic_quotes_active ) { $value = addslashes( $value ); }
  92. }
  93. return $value;
  94. }
  95. public function close_connection() {
  96. if(isset($this->conn)) {
  97. mysql_close($this->conn);
  98. unset($this->conn);
  99. }
  100. }
  101. }
  102. $mydb = new Database();
  103. ?>
And for the Login Script
  1. <?php
  2. if (isset($_POST['btnlogin'])){
  3. $email = trim($_POST['log_email']);
  4. $upass = trim($_POST['log_pword']);
  5. $h_upass = sha1($upass);
  6. if($email == ''){
  7. echo 'Username or Password Not Registered! Contact Your administrator...';
  8. }elseif($upass == ''){
  9. echo 'Username or Password Not Registered! Contact Your administrator...';
  10. }else{
  11. $sql = "SELECT * FROM `user_info` WHERE `email`='". $email ."' and `pword`='". $h_upass ."'";
  12. $result = mysql_query($sql) or die;
  13. echo $numrows = mysql_num_rows($result);
  14. if ($numrows == 1){
  15. $found_user = mysql_fetch_array($result);
  16. $_SESSION['member_id'] = $found_user['member_id'];
  17. $_SESSION['fName'] = $found_user['fName'];
  18. $_SESSION['lName'] = $found_user['lName'];
  19. $_SESSION['email'] = $found_user['email'];
  20. $_SESSION['pword'] = $found_user['pword'];
  21. $_SESSION['gender'] = $found_user['gender'];
  22. ?> <script type="text/javascript">
  23. window.location = "home.php";
  24. </script>
  25. <?php
  26. }else{
  27. ?> <script type="text/javascript">
  28. alert("Username or Password Not Registered! Contact Your administrator.");
  29. window.location = "home.php";
  30. </script>
  31. <?php
  32. }
  33. }
  34. }else{
  35. $email = "";
  36. $upass = "";
  37. $utype = "";
  38. }
  39.  
  40. ?>
Sample Image Result For more tutorials just visit this website @www.sourcecodester.com and don't forget to Like and Share. Enjoy Coding.

Add new comment