Results 1 to 5 of 5

Thread: PM system Reply

  1. #1
    Join Date
    Jun 2009
    Posts
    62
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default PM system Reply

    I have a database with all my members messages in it.
    id | to | from | subject | message
    When someone replies to a message, the URL is reply.php?id=(whatever id the initial message was)
    The problem is, someone could randomy type in the url reply.php?id=55 if they have a user and pass.
    They don't nessacarily have to be the replier of the message.
    I have:
    $result = mysql_query("SELECT * FROM `messages` WHERE `to` = '$username'");
    $row = mysql_fetch_array($result)
    So is it possible to have an if else statement. (This obviously doesn't work, I am just trying to show you what I mean.)
    if ($_GET['id'] != an id that belongs to this user in the field to)
    {echo "You are on the wrong page;"}
    else
    {
    //php reply form
    }

    I think I have to change $row = mysql_fetch_array to some other string but I'm not sure.

    Sorry this is a bit confusing, but I hope you understand.

  2. #2
    Join Date
    Jun 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yes, you can have the conditional prior to loading the reply section being built

    PHP Code:

    $sql statement
    ()
    if (
    validation of user matches id of the intended receiver in that message) {
        while{
               [
    B][COLOR="SeaGreen"]build good reply statement.[/COLOR][/B]
               }
    else
    {
    [
    COLOR="Red"][B]hey buddy you don't belong to this PM - GET OUT! - ADMIN OF SITE NOTIFIED!!![/B][/COLOR]
    send email to admin of attempted user information leak.


  3. #3
    Join Date
    Jun 2009
    Posts
    62
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply. I see what your saying, but obviously I can't use "validation of user matches id of the intended receiver in that message"
    So what would I use is what I'm stuck on.
    If I say:
    PHP Code:
    if($to != $id
    it allows say id 1 but not id 2.
    Thanks
    P.S. I like the send Admin an email alert idea!!

  4. #4
    Join Date
    Jun 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    so, your sql statement should be comparing the user sumbitted via the link (via cookie login info stored?) to the original destination user id of the Message...

    the if statement uses that condtional for it's evaluation

    PHP Code:
    $sql statement
    if row('newuser') = row('originaluser') {
    build out the reply page you could include the orginal sql in here to build out the reply page. or modify the sql to ensure its got the right user in here.
    }
    else
    {
    $error "you arent allowed to see this post. admin notified."
    // email admin account
    email_error($row('newuser'),(timestamp), (ip), ... <whatever information you can get from the browser>) 
    // display the login page with message above.
    rebuild_login_page($error);


    Does the database keep user information for the PM's? meaning you have two tables your comparing

    1 user
    2 pm's

    the user table obviously has user accounts, but does the PM's table? if it does, do a join based off the pm message id orginal user and the account of the poster, if they match build if not... admin email.

  5. #5
    Join Date
    Jun 2009
    Posts
    62
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    Yes I have the same two tables and no I am using sessions not cookies.
    But what do you mean by 'build' and 'join'? I'm not sure what you mean.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •