Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy post is not posting :( please help!

    ive been to so many forums and no one has been able to help me please help...

    ok well im changing my sites way of posting , but i dont know why its not posting... here are the scripts and codes , i cant piece it together .

    Here is profile.php where i have the original script to call on the ajax script to post the post.
    profile.php (segment)
    PHP Code:
    $the_blab_form 
             
      <textarea id="add-status"class="status" onkeyup="limitText(this,350,\'.character-count\');detect_url(this.value);" onclick="limitText(this,350,\'.character-count\');detect_url(this.value);"></textarea><div><input class="button post" type="button" value="Post" id="'
    .$session.'" onClick="add_post(this.id)"/><div class="character-count">350</div>
              '

    now the functions that it is using is in my javascript file which is below...
    sitewide.js (segment)
    Code:
    function add_post(id)
    {
    
    if($('.post').attr('title', 'Active'))
    {
    var o_post = $("#add-status").val();
    var post = encodeURIComponent(o_post.replace(/^\s+|\s+$/g, ''));
    if(post)
    {
    $('.post').attr('title', 'Inactive');
    $(".post-loading").show();
    $.ajax({
    type: "POST",
    url: "add/post.php",
    data: "post="+post+"&id="+id,
    cache: false,
    success: function(html){
    $(".stream").prepend(html);
     $('.stream li:first').show('drop', { direction: 'up' }, 500);
    $('.post').attr('title', 'Active');
    $("#add-status").val('');
    $(".share-wrapper > a").click();
    $(".post-loading").hide();
    $(".preview-wrapper").empty();
    }
    });	
    	
    	
    }
    }
    
    }
    now the php file that it uses to post the post is right here below...
    add/post.php (whole script)
    PHP Code:
    <?php include("../includes.php");
    $session $logOptions_id;
    if(
    $session)
    {
    $id $_POST['id'];
    if(!
    $id)
    {
    $id $session;    
    }
    $post mysql_real_escape_string($_POST['post']);
    $date mktime();


    list(
    $url$thumbnail$title$description$videoID) = check_url($post);
    if(
    $url)
    {
        
    $action_type 1;
        
        
    $tags get_meta_tags($url);
        
    $title $tags['title'];
        
    $description strip_tags(mysql_real_escape_string($tags['description']));
        
    mysql_query("INSERT INTO link_info SET user_id='$session', title='$title', description='$description', link='$url', date='$date'");
    }
    else
    {
        
    $action_type 0;
    }


    mysql_query("INSERT INTO posts SET to_id='$id',from_id='$session',post='$post',type='$action_type',date='$date'");
    $post_id mysql_insert_id();

    $query mysql_query("SELECT id,to_id,from_id,post,type,state,date FROM posts WHERE id='$post_id' AND state='0' ORDER BY id DESC LIMIT 15");    
    print 
    posts($query"newPost");

    if(
    $id!=$session)
    {
    mysql_query("INSERT INTO notifications SET user_id='$id', from_id='$session', post_id='$post_id', action_type='$action_type', date='$date'");
    }

    }
    ?>
    now the includes file is below , it includes the functions , and the connections...
    includes.php
    PHP Code:
    <?php error_reporting(0);
    include(
    "connect_to_mysql.php");
    include(
    "date_time.php"); 
    include(
    "functions.php");
    include(
    "scripts/checkuserlog.php");
    $currentFile $_SERVER["SCRIPT_NAME"];
    $parts explode('/'$currentFile);
    $check_path $parts[count($parts) - 2];
    $currentFile $parts[count($parts) - 1];
    ?>
    now here is the functions segment where my post function is in...
    functions.php (segment)
    PHP Code:
    function posts($query, $action_type)
    {
    $session = $logOptions_id;
    if($action_type=="newPost")
    {
        $class = "class='new'";
    }
    else
    {
        $class = "";
    }

    while($row = mysql_fetch_array($query))
    {
    $id = $row['id'];
    $to_id = $row['to_id'];
    $from_id = $row['from_id'];
    $post = stripslashes(linkify(nl2br(htmlentities($row['post']))));
    $type = $row['type'];
    $state = $row['state'];
    $date = time_stamp($row['date']);

    $name = name($from_id);
    $photo = photo($from_id, 55);


    $num_likes = mysql_num_rows(mysql_query("SELECT id FROM db_like WHERE post_id='$id'"));
    if($num_likes == 0)
    {
        $num_likes = '';
    }
    else if($num_likes == 1)
    {
        $num_likes = $num_likes." person likes this";    
    }
    else
    {
        $num_likes = $num_likes." people like this";
    }

    $query_like = mysql_fetch_assoc(mysql_query("SELECT id FROM db_like WHERE post_id='$id' AND from_id='$session'"));
    if($query_like)
    {$like_unlike = "unlike";}
    else
    {$like_unlike = "like";}

    if($from_id==$session)
    {
    $session_photo = "class='post-photo".$session."'";    
    }else{$session_photo = "";}

    if($action_type!="noLi")
    {
    ?>
    <li <?php print $class?> id="<?php print $id?>"><?php }?>
    <div>
    <div class="post-left"><img <?php $session_photo?> src="<?php print $photo?>" /></div>
    <div class="post-right">
    <!---ARROW-->
    <div class="arrow-border"><div class="arrow"></div></div>
    <!------->

    <?php if($to_id==$session||$from_id==$session){?>
    <div class="post-remove" onClick="remove_post('<?php print $id?>')">X</div>
    <?php }?>
    <?php 
    if($type == 1)
    {
    list(
    $url$thumbnail$title$description$videoID) = check_url($post);
    $post str_replace($url''$post);    
    }
    ?>
    <div class="post-body"><?php print $post?></div>
    <?php if($type==1)
    {
    ?>
    <div class="post-link-container">
    <div class="post-link-left"><img onClick="play_Video('<?php print $videoID?>', '<?php print $from_id?>', '<?php print $id?>');" src="<?php print $thumbnail?>"/></div>
    <div class="post-link-right">
    <div class="post-link-title"><?php print $title?></div><div class="post-link-description"><?php print $description?></div>

    </div>
    </div>
    <?php }?>

    <div class="post-top">
    <a class="post-name" href="#/profile&id=<?php print $from_id?>"><?php print $name?></a> | <a href="#/posts&id=<?php print $id?>" class="post-date" title="<?php print date('l, jS \of F, Y \a\t g:ia '$row['date']+60*60);?>"><?php print $date?></a> | <a class="post-comment" id="comment-toggle<?php print $id?>" onClick="comment_toggle('<?php print $id?>')">Comment</a> | <a class="post-like" id="PostLike<?php print $id?>" onClick="<?php print $like_unlike?>('<?php print $id?>')"><?php print ucwords($like_unlike)?></a> <div class="num-likes" id="NumLikes<?php print $id?>"><?php print $num_likes?></div>

    </div>

    </div>
    </div>
    and finaly here is the script for the $logoptions , i think this is where everything is not working... i have $session=$logOptions_id in the add/post.php but here is the script.
    checkuserlog.php (whole script)
    PHP Code:
    <?php

    session_start
    (); // Start Session First Thing
    // Force script errors and warnings to show on page in case php.ini file is set to not display them
    error_reporting();
    ini_set('display_errors''1');
    //-----------------------------------------------------------------------------------------------------------------------------------
    include_once "connect_to_mysql.php"// Connect to the database
    $dyn_www $_SERVER['HTTP_HOST']; // Dynamic www.domainName available now to you in all of your scripts that include this file
    //------ CHECK IF THE USER IS LOGGED IN OR NOT AND GIVE APPROPRIATE OUTPUT -------
    $logOptions ''// Initialize the logOptions variable that gets printed to the page
    // If the session variable and cookie variable are not set this code runs
    if (!isset($_SESSION['idx'])) { 
      if (!isset(
    $_COOKIE['idCookie'])) {
         
    $logOptions '<a href="http://' $dyn_www '/webinter/register.php">Register Account</a>
         &nbsp;&nbsp; | &nbsp;&nbsp; 
         <a href="http://' 
    $dyn_www '/webinter/login.php">Log In</a>';
       }
    }
    // If session ID is set for logged in user without cookies remember me feature set
    if (isset($_SESSION['idx'])) { 
        
        
    $decryptedID base64_decode($_SESSION['idx']);
        
    $id_array explode("p3h9xfn8sq03hs2234"$decryptedID);
        
    $logOptions_id $id_array[1];
        
    $logOptions_username $_SESSION['username'];
        
    $logOptions_username substr('' $logOptions_username ''015); // cut user name down in length if too long
        
        // Check if this user has any new PMs and construct which envelope to show
        
    $sql_pm_check mysql_query("SELECT id FROM private_messages WHERE to_id='$logOptions_id' AND opened='0' LIMIT 1");
        
    $num_new_pm mysql_num_rows($sql_pm_check);
        if (
    $num_new_pm 0) {
            
    $PM_envelope '<a href="pm_inbox.php"><img src="./images/pm2.gif" width="18" height="11" alt="PM" /></a>';
        } else {
            
    $PM_envelope '<a href="pm_inbox.php"><img src="./images/pm1.gif" width="18" height="11" alt="PM" /></a>';
        }
        
    // Ready the output for this logged in user
        
    $logOptions $PM_envelope ' &nbsp; &nbsp;
        <a href="http://' 
    $dyn_www '/webinter/profile.php?id=' $logOptions_id '">Profile</a>
        &nbsp;&nbsp; |&nbsp;&nbsp;
        <div class="dc">
    <a href="#" onclick="return false">Account &nbsp; <img src="./images/darr.gif" width="10" height="5" alt="Account Options" border="0"/></a>
    <ul>
    <li><a href="http://' 
    $dyn_www '/webinter/edit_profile.php">Account Options</a></li>
    <li><a href="http://' 
    $dyn_www '/webinter/pm_inbox.php">Inbox Messages</a></li>
    <li><a href="http://' 
    $dyn_www '/webinter/pm_sentbox.php">Sent Messages</a></li>
    </ul>
    </div>
        
        &nbsp;&nbsp; |&nbsp;&nbsp;
        <a href="http://' 
    $dyn_www '/webinter/logout.php">Log Out</a>';

    } else if (isset(
    $_COOKIE['idCookie'])) {// If id cookie is set, but no session ID is set yet, we set it below and update stuff
        
        
    $decryptedID base64_decode($_COOKIE['idCookie']);
        
    $id_array explode("nm2c0c4y3dn3727553"$decryptedID);
        
    $userID $id_array[0]; 
        
    $userPass $_COOKIE['passCookie'];
        
    // Get their user first name to set into session var
        
    $sql_uname mysql_query("SELECT username FROM myMembers WHERE id='$userID' AND password='$userPass' LIMIT 1");
        
    $numRows mysql_num_rows($sql_uname);
        if (
    $numRows == 0) {
            echo 
    '<script language="Javascript">';
    echo 
    'window.location="index.php"';
    echo 
    '</script>';
            exit();
        }
        while(
    $row mysql_fetch_array($sql_uname)){ 
            
    $username $row["username"];
        }

        
    $_SESSION['id'] = $userID// now add the value we need to the session variable
        
    $_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$userID");
        
    $_SESSION['username'] = $username;

        
    $logOptions_id $userID;
        
    $logOptions_uname $username;
        
    $logOptions_uname substr('' $logOptions_uname ''015); 
        
    ///////////          Update Last Login Date Field       /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        
    mysql_query("UPDATE myMembers SET last_log_date=now() WHERE id='$logOptions_id'"); 
        
    // Ready the output for this logged in user
        // Check if this user has any new PMs and construct which envelope to show
        
    $sql_pm_check mysql_query("SELECT id FROM private_messages WHERE to_id='$logOptions_id' AND opened='0' LIMIT 1");
        
    $num_new_pm mysql_num_rows($sql_pm_check);
        if (
    $num_new_pm 0) {
            
    $PM_envelope '<a href="pm_inbox.php"><img src="./images/pm2.gif" width="18" height="11" alt="PM" /></a>';
        } else {
            
    $PM_envelope '<a href="pm_inbox.php"><img src="./images/pm1.gif" width="18" height="11" alt="PM" /></a>';
        }
        
    // Ready the output for this logged in user
         
    $logOptions $PM_envelope ' &nbsp; &nbsp;
         <a href="http://' 
    $dyn_www '/profile.php?id=' $logOptions_id '">Profile</a>
        &nbsp;&nbsp; |&nbsp;&nbsp;
        <div class="dc">
    <a href="#" onclick="return false">Account &nbsp; <img src="./images/darr.gif" width="10" height="5" alt="Account Options" border="0"/></a>
    <ul>
    <li><a href="http://' 
    $dyn_www '/webinter/edit_profile.php">Account Options</a></li>
    <li><a href="http://' 
    $dyn_www '/webinter/pm_inbox.php">Inbox Messages</a></li>
    <li><a href="http://' 
    $dyn_www '/webinter/pm_sentbox.php">Sent Messages</a></li>
    </ul>
    </div>
        
        &nbsp;&nbsp; |&nbsp;&nbsp;
        <a href="http://' 
    $dyn_www '/webinter/logout.php">Log Out</a>';
    }
    ?>
    if there is another way to set up my site please help me.... THANK YOU

  • #2
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    holy crap... that's a lot of code for a simple form post....

    break it down to basics and work through it piece by piece

  • Users who have thanked jmj001 for this post:

    Glenskie (01-27-2012)

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Hey i wana thank you

    hey thank you you are literally the only one who even tryed to help me , i figured it out on my own thanks...


  •  

    Tags for this Thread

    Posting Permissions

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