Fri. Dec 6th, 2019

Host your Website

Read and learn

FatCow Web Hosting $1.00/mo* Trust your web hosting to the #1 web host provider, GoDaddy!

Chat application in PHP & MySQL: Send and receive messages part4

1 min read



Chat application in PHP & MySQL using Ratchet Library
web socket programming
Send and receive messages

Share, Support, Subscribe!!!
Youtube: https://www.youtube.com/learnWebCoding
Facebook: https://www.facebook.com/learnWebCoding
Blog: http://dwebcoding.blogspot.com/
GitHub: https://github.com/durgesh-sahani

Connect with Me:
Linkedin: https://www.linkedin.com/in/durgesh-sahani
Facebook: https://www.facebook.com/durgeshsahani99
Instagram: https://www.instagram.com/durgesh_sahani99/
Twitter: https://twitter.com/durgeshsahani99
Skype: https://join.skype.com/invite/hYkWG7Rg6Usa

16 thoughts on “Chat application in PHP & MySQL: Send and receive messages part4

  1. Im Getting {"userId":"7","msg":"hi","from":null,"dt":"31-10-19 12:23:26"} please help me to fix this. I made all this correct
    require ("../db/users.php");
    And following changes were made

    $data = json_decode($msg,true);

    $objUser = new users;

    $objUser->setId($data['UserId']);

    $user = $objUser->getUserById();

    $data['from'] = $data['UserId'];

    $data['msg'] = $data['msg'];

    $data['dt'] = date("d-m-y h:i:s");

  2. <?php

    require_once 'header.php';

    if (!$loggedin) die();

    $query = $link->query("SELECT * FROM images ORDER BY uploaded_on DESC");

    if($query->num_rows > 0){
    while($row = $query->fetch_assoc()){

    $imageURL = 'uploads/'.$row["file_name"];
    ?>

    <img src="<?php echo $imageURL; ?> " alt="" height="200" width="220" ;/>

    <?php echo "<p>".$row['image_text']."</p>";
    ?>

    <a href="messages.php? receive=<?php echo $row["uploader"]

    ?>"class="link">Send message</a>

    <?php }

    }else{ ?>

    <p>No image(s) found…</p>

    <?php } ?>

    I have a page that displays all images uploaded by all users. On each image there is a link "send message". How can i really send a message to the uploader/owner of the image when am logged in.

    Please just help!!!!!

  3. Just pointing out that your code has security implications. I can send any user_id from client side and pretend to be any user without logging in.

Comments are closed.

Copyright © All rights reserved. | Newsphere by AF themes.