[SOLVED] PM Get users javascript help

  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post May 19th, 2009, 12:06 am

I don't really know the best way to describe this, but here's my try at it.

I am in the process of finishing my PM system.

Let's say a user is writing a PM to someone... there would be a link besides the To: field which says 'Find a user'. When the user clicks that link, a pop-up pops up populated with all the username in the user tables in my MySQL database. Maybe even a search box that when submitted, returns the result in that pop-up. If a user clicks on a username, then that username would appear in the To: field, but the pop-up would stay, and if the user clicks 'Close', the pop-up closes.

A solution to this would be very helpful and appreciated.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 19th, 2009, 12:06 am

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 3415
  • Loc: Richland, WA
  • Status: Offline

Post May 19th, 2009, 12:56 am

Code: [ Select ]
function insert_single(user)
{
    opener.document.forms['postform'].username_list.value = user;
}
  1. function insert_single(user)
  2. {
  3.     opener.document.forms['postform'].username_list.value = user;
  4. }


opener is defined as the window that is a parent to the popup.

http://www.javascriptkit.com/javatutors/remote2.shtml
#define NULL (::rand() % 2)
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post May 19th, 2009, 9:04 am

I have no idea how to use that code.

My Test code is:
Code: [ Select ]
<html>
    <head>
        <title>Test JS Document</title>
        <script type="javascript">
        function insert_single(user)
        {
            document.forms['postform'].username_list.value = user;
        }
        </script>
    </head>
    <body>
    <form name="postform" action="" method="post">
        <p>
            User: <input type="text" name="username_list" id="username_list" size="25" /> [<a href="javascript&#058;insert_single('Bogey')">Pick A User</a>]
        </p>
    </form>
    </body>
</html>
  1. <html>
  2.     <head>
  3.         <title>Test JS Document</title>
  4.         <script type="javascript">
  5.         function insert_single(user)
  6.         {
  7.             document.forms['postform'].username_list.value = user;
  8.         }
  9.         </script>
  10.     </head>
  11.     <body>
  12.     <form name="postform" action="" method="post">
  13.         <p>
  14.             User: <input type="text" name="username_list" id="username_list" size="25" /> [<a href="javascript&#058;insert_single('Bogey')">Pick A User</a>]
  15.         </p>
  16.     </form>
  17.     </body>
  18. </html>

Now, I know it wouldn't open a pop-up and give me a list of users... I know that all the code is doing is getting the user to the form field... for now, I removed 'opener.' since I'm testing this on the main window and not a pop-up, but I still can't get it to put 'Bogey' into the field.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 3415
  • Loc: Richland, WA
  • Status: Offline

Post May 19th, 2009, 2:16 pm

The following worked for me

Code: [ Select ]
<html>
    <head>
        <title>Test JS Document</title>
        <script type="text/javascript">
        function insert_single(user)
        {
            document.forms['postform'].username_list.value = user;
        }
        </script>
    </head>
    <body>
    <form name="postform" action="" method="post">
        <p>
            User: <input type="text" name="username_list" id="username_list" size="25" /> [<a href="#" onclick="insert_single('Bogey'); return false;">Pick A User</a>]
        </p>
    </form>
    </body>
</html>
  1. <html>
  2.     <head>
  3.         <title>Test JS Document</title>
  4.         <script type="text/javascript">
  5.         function insert_single(user)
  6.         {
  7.             document.forms['postform'].username_list.value = user;
  8.         }
  9.         </script>
  10.     </head>
  11.     <body>
  12.     <form name="postform" action="" method="post">
  13.         <p>
  14.             User: <input type="text" name="username_list" id="username_list" size="25" /> [<a href="#" onclick="insert_single('Bogey'); return false;">Pick A User</a>]
  15.         </p>
  16.     </form>
  17.     </body>
  18. </html>
#define NULL (::rand() % 2)
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post May 19th, 2009, 2:26 pm

SpooF wrote:
The following worked for me

Code: [ Select ]
<html>
    <head>
        <title>Test JS Document</title>
        <script type="text/javascript">
        function insert_single(user)
        {
            document.forms['postform'].username_list.value = user;
        }
        </script>
    </head>
    <body>
    <form name="postform" action="" method="post">
        <p>
            User: <input type="text" name="username_list" id="username_list" size="25" /> [<a href="#" onclick="insert_single('Bogey'); return false;">Pick A User</a>]
        </p>
    </form>
    </body>
</html>
  1. <html>
  2.     <head>
  3.         <title>Test JS Document</title>
  4.         <script type="text/javascript">
  5.         function insert_single(user)
  6.         {
  7.             document.forms['postform'].username_list.value = user;
  8.         }
  9.         </script>
  10.     </head>
  11.     <body>
  12.     <form name="postform" action="" method="post">
  13.         <p>
  14.             User: <input type="text" name="username_list" id="username_list" size="25" /> [<a href="#" onclick="insert_single('Bogey'); return false;">Pick A User</a>]
  15.         </p>
  16.     </form>
  17.     </body>
  18. </html>

Alright that works... thanks a bunch... another thing :| How could I make it so that it adds more if there is already something in the field?

Also, is it possible to do that without the name in form? It doesn't validate in XHTML strict.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 3415
  • Loc: Richland, WA
  • Status: Offline

Post May 19th, 2009, 5:06 pm

Code: [ Select ]
document.forms['postform'].username_list.value += user;

Its either += or =+
#define NULL (::rand() % 2)
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post May 19th, 2009, 8:46 pm

It's +=...

Also, the following made it "XHTML Strict legal":
Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 
    <head>
        <title>Test JS Document</title>
        <script type="text/javascript">
        function insert_single(user)
        {
            var el = document.getElementById('postform');
 
            el.username_list.value += user;
        }
        </script>
    </head>
    <body>
    <form id="postform" action="" method="post">
        <p>
            User: <input type="text" name="username_list" id="username_list" size="25" /> [<a href="#" onclick="insert_single('Bogey'); return false;">Pick A User</a>]
        </p>
    </form>
    </body>
</html>
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  4.  
  5.     <head>
  6.         <title>Test JS Document</title>
  7.         <script type="text/javascript">
  8.         function insert_single(user)
  9.         {
  10.             var el = document.getElementById('postform');
  11.  
  12.             el.username_list.value += user;
  13.         }
  14.         </script>
  15.     </head>
  16.     <body>
  17.     <form id="postform" action="" method="post">
  18.         <p>
  19.             User: <input type="text" name="username_list" id="username_list" size="25" /> [<a href="#" onclick="insert_single('Bogey'); return false;">Pick A User</a>]
  20.         </p>
  21.     </form>
  22.     </body>
  23. </html>


Another thing... how could I add a comma and a space ", " before the username if there is already one in the field? Sorry to ask so much from you SpooF. I appreciate your help and thank you :D

[EDIT:] Never mind the following javascript did it...
Code: [ Select ]
function insert_single(user)
{
    var el = document.getElementById('postform');

    if(el.username_list.value.length > 0)
    {
        el.username_list.value += ", " + user;
    }
    else
    {
        el.username_list.value = user;
    }
}
  1. function insert_single(user)
  2. {
  3.     var el = document.getElementById('postform');
  4.     if(el.username_list.value.length > 0)
  5.     {
  6.         el.username_list.value += ", " + user;
  7.     }
  8.     else
  9.     {
  10.         el.username_list.value = user;
  11.     }
  12. }

Is there a better way?
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post May 19th, 2009, 9:46 pm

Thank's SpooF... I got it all figured out and working :D


BUT, one more thing that I have a problem here... this thing messes up my site... after I use it and close the window, if I try to do anything my whole site turns blank... just white... no HTML or anything... only way to fix that is to clear cookies and that would log me out... how could I fix that?

Thanks.

The source of the popup is:
Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title>Test JS Document</title>
        <script type="text/javascript">
        function insert_single(user)
        {
            opener.validate_field('pm_form', user)
        }
        </script>
    </head>
    <body>
        <?php
            require_once 'includes/globals.php';
            
            $userlist = $auth->get_user_list('username');
            $num_users = count($userlist);
            
            $n = 0;
            foreach($userlist as $user)
            {
                ++$n;
                
                echo "<a href=\"#\" onclick=\"insert_single('$user')\">$user</a>";
                
                if($n > 0 && $n < $num_users)
                {
                    echo ",\n ";
                }
            }
        ?>
    </body>
</html>
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  4.     <head>
  5.         <title>Test JS Document</title>
  6.         <script type="text/javascript">
  7.         function insert_single(user)
  8.         {
  9.             opener.validate_field('pm_form', user)
  10.         }
  11.         </script>
  12.     </head>
  13.     <body>
  14.         <?php
  15.             require_once 'includes/globals.php';
  16.             
  17.             $userlist = $auth->get_user_list('username');
  18.             $num_users = count($userlist);
  19.             
  20.             $n = 0;
  21.             foreach($userlist as $user)
  22.             {
  23.                 ++$n;
  24.                 
  25.                 echo "<a href=\"#\" onclick=\"insert_single('$user')\">$user</a>";
  26.                 
  27.                 if($n > 0 && $n < $num_users)
  28.                 {
  29.                     echo ",\n ";
  30.                 }
  31.             }
  32.         ?>
  33.     </body>
  34. </html>

Which looks like the following in the end:
Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title>Test JS Document</title>
        <script type="text/javascript">
        function insert_single(user)
        {
            opener.validate_field('pm_form', user)
        }
        </script>
    </head>
    <body>
        <a href="#" onclick="insert_single('Bogey')">Bogey</a>, <a href="#" onclick="insert_single('Boris')">Boris</a>,
<a href="#" onclick="insert_single('Brandon')">Brandon</a>,
<a href="#" onclick="insert_single('craig')">craig</a>,
<a href="#" onclick="insert_single('frog')">frog</a>
    </body>
</html>
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  4.     <head>
  5.         <title>Test JS Document</title>
  6.         <script type="text/javascript">
  7.         function insert_single(user)
  8.         {
  9.             opener.validate_field('pm_form', user)
  10.         }
  11.         </script>
  12.     </head>
  13.     <body>
  14.         <a href="#" onclick="insert_single('Bogey')">Bogey</a>, <a href="#" onclick="insert_single('Boris')">Boris</a>,
  15. <a href="#" onclick="insert_single('Brandon')">Brandon</a>,
  16. <a href="#" onclick="insert_single('craig')">craig</a>,
  17. <a href="#" onclick="insert_single('frog')">frog</a>
  18.     </body>
  19. </html>

And the opener page looks like:
Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-gb" xml:lang="en-gb">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta name="verify-v1" content="UHKQaB5BfCapubuxANzYjxmg0b0Y2rxpaJ9P5RM1ADg=" />
        <link href="./templates/wedevoy/style/style.css" rel="stylesheet" type="text/css" />
        <link rel="shortcut icon" href="./templates/wedevoy/images/favicon.png" />
        <script type="text/javascript">
        function validate_field(field_id, value)
        {
            var el = document.getElementById(field_id);

            if(el.to.value.length > 0)
            {
                el.to.value += ", " + value;
            }
            else
            {
                el.to.value = value;
            }
        }
        
        function popup(page)
        {
            mywindow = window.open(page,"mywindow","location=1,status=1,scrollbars=1, width=600, height=500");
            mywindow.moveTo(0,0);
        }
        </script>
        <title>Wedevoy • Private Mail: Compose</title>
    </head>
    <body>
        <div id="header">
            <h1 id="logo" class="logo"></h1>
            <div id="info">
                <h2>Announcement</h2>
                <p>This site is in it's early stage of development... you may notice a few grammatical errors or design flaws as we have not had the time to refactor any of our coding or content. Thank you for your patience!</p>
            </div>
        </div>
        <div id="tnav">
            <ul id="top_nav">
                <li><a href="./index.php">Home</a></li>
                <li><a class="trigger" href="users.php">Membership</a>
                    <ul>
                        <li><a href="?logout">Log-Out [Bogey]</a></li>
                        <li><a href="pm.php">Private Mail</a></li>
                        <li><a href="ucp.php">User Control Panel</a></li>
                        <li><a href="acp.php">Admin Control Panel</a></li>
                    </ul>
                </li>
                <li><a class="trigger" href="./services.php">Services</a>

                    <ul>
                        <li><a href="img2html.php">Image to HTML</a></li>
                        <li><a href="music.php">Music / Audio</a></li>
                        <li><a href="refactor.php">Refactoring Code</a></li>
                        <li><a href="web.php">Web Design</a></li>
                        <li><a href="programming.php">Web Programming</a></li>

                        <li><a href="review.php">Website Review</a></li>
                    </ul>
                </li>
                <li><a class="trigger" href="./support.php">Support</a>
                    <ul>
                        <li><a href="./about.php">About Us</a></li>

                        <li><a href="./contact.php">Contact Us</a></li>
                    </ul>
                </li>
                <li><a class="trigger" href="./tutorials.php">Tutorials</a>
                    <ul>
                        <li><a href="tutorials.php?create">Create Tutorial</a></li>
                        <li><a href="tutorials.php?search">Search Tutorials</a></li>
                    </ul>
                </li>
                <li><a class="trigger" href="./sreviews.php">Site Reviews</a>
                    <ul>
                        <li><a href="rreview.php">Site Review Requests</a></li>
                    </ul>
                </li>
            </ul>
        </div>
        <div id="container">
            <div id="nav">
                <div class="first">
                    <ul class="navlinks">
                        <li class="head">Private Mail</li>
                        <li><a href="pm.php?page=compose">Compose PM</a></li>
                    </ul>
                </div>
                <ul class="navlinks">
                    <li class="head">Site Links</li>
                    <li><a href="vreview.php">View your site review</a></li>
                    <li><a href="donate.php">Donate</a></li>
                </ul>
            </div>
            <div id="body">
                <h1>Private Mail: Compose</h1>
                <form action="pm.php?page=compose" method="post" id="pm_form">
                    <p class="formf">
                        <label for="to">To:</label><br />
                        <label for="subject">Subject:</label><br />
                    </p>
                    <p class="formf">
                        <input type="text" name="to" id="to" size="25" /> [<a href="" onclick="popup('user_list.php'); return false;">Find a user</a>]<br />
                        <input type="text" name="subject" id="subject" size="25" /><br />
                    </p>
                    <p style="clear: both;">
                        <label for="message">Message:</label><br />
                        <textarea name="message" id="message" cols="60" rows="10"></textarea><br />
                        <input type="submit" name="submit" value="Send" /> <input type="reset" name="reset" value="Reset" />
                    </p>
                </form>
            </div>
            <p style="clear: both;"></p>
        </div>
        <div id="footer">
            <p>Copyright © 2009 - 2010 <a href="http://www.wedevoy.com">Wedevoy.com</a></p>
        </div>
    </body>
</html>
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-gb" xml:lang="en-gb">
  3.     <head>
  4.         <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  5.         <meta name="verify-v1" content="UHKQaB5BfCapubuxANzYjxmg0b0Y2rxpaJ9P5RM1ADg=" />
  6.         <link href="./templates/wedevoy/style/style.css" rel="stylesheet" type="text/css" />
  7.         <link rel="shortcut icon" href="./templates/wedevoy/images/favicon.png" />
  8.         <script type="text/javascript">
  9.         function validate_field(field_id, value)
  10.         {
  11.             var el = document.getElementById(field_id);
  12.             if(el.to.value.length > 0)
  13.             {
  14.                 el.to.value += ", " + value;
  15.             }
  16.             else
  17.             {
  18.                 el.to.value = value;
  19.             }
  20.         }
  21.         
  22.         function popup(page)
  23.         {
  24.             mywindow = window.open(page,"mywindow","location=1,status=1,scrollbars=1, width=600, height=500");
  25.             mywindow.moveTo(0,0);
  26.         }
  27.         </script>
  28.         <title>Wedevoy • Private Mail: Compose</title>
  29.     </head>
  30.     <body>
  31.         <div id="header">
  32.             <h1 id="logo" class="logo"></h1>
  33.             <div id="info">
  34.                 <h2>Announcement</h2>
  35.                 <p>This site is in it's early stage of development... you may notice a few grammatical errors or design flaws as we have not had the time to refactor any of our coding or content. Thank you for your patience!</p>
  36.             </div>
  37.         </div>
  38.         <div id="tnav">
  39.             <ul id="top_nav">
  40.                 <li><a href="./index.php">Home</a></li>
  41.                 <li><a class="trigger" href="users.php">Membership</a>
  42.                     <ul>
  43.                         <li><a href="?logout">Log-Out [Bogey]</a></li>
  44.                         <li><a href="pm.php">Private Mail</a></li>
  45.                         <li><a href="ucp.php">User Control Panel</a></li>
  46.                         <li><a href="acp.php">Admin Control Panel</a></li>
  47.                     </ul>
  48.                 </li>
  49.                 <li><a class="trigger" href="./services.php">Services</a>
  50.                     <ul>
  51.                         <li><a href="img2html.php">Image to HTML</a></li>
  52.                         <li><a href="music.php">Music / Audio</a></li>
  53.                         <li><a href="refactor.php">Refactoring Code</a></li>
  54.                         <li><a href="web.php">Web Design</a></li>
  55.                         <li><a href="programming.php">Web Programming</a></li>
  56.                         <li><a href="review.php">Website Review</a></li>
  57.                     </ul>
  58.                 </li>
  59.                 <li><a class="trigger" href="./support.php">Support</a>
  60.                     <ul>
  61.                         <li><a href="./about.php">About Us</a></li>
  62.                         <li><a href="./contact.php">Contact Us</a></li>
  63.                     </ul>
  64.                 </li>
  65.                 <li><a class="trigger" href="./tutorials.php">Tutorials</a>
  66.                     <ul>
  67.                         <li><a href="tutorials.php?create">Create Tutorial</a></li>
  68.                         <li><a href="tutorials.php?search">Search Tutorials</a></li>
  69.                     </ul>
  70.                 </li>
  71.                 <li><a class="trigger" href="./sreviews.php">Site Reviews</a>
  72.                     <ul>
  73.                         <li><a href="rreview.php">Site Review Requests</a></li>
  74.                     </ul>
  75.                 </li>
  76.             </ul>
  77.         </div>
  78.         <div id="container">
  79.             <div id="nav">
  80.                 <div class="first">
  81.                     <ul class="navlinks">
  82.                         <li class="head">Private Mail</li>
  83.                         <li><a href="pm.php?page=compose">Compose PM</a></li>
  84.                     </ul>
  85.                 </div>
  86.                 <ul class="navlinks">
  87.                     <li class="head">Site Links</li>
  88.                     <li><a href="vreview.php">View your site review</a></li>
  89.                     <li><a href="donate.php">Donate</a></li>
  90.                 </ul>
  91.             </div>
  92.             <div id="body">
  93.                 <h1>Private Mail: Compose</h1>
  94.                 <form action="pm.php?page=compose" method="post" id="pm_form">
  95.                     <p class="formf">
  96.                         <label for="to">To:</label><br />
  97.                         <label for="subject">Subject:</label><br />
  98.                     </p>
  99.                     <p class="formf">
  100.                         <input type="text" name="to" id="to" size="25" /> [<a href="" onclick="popup('user_list.php'); return false;">Find a user</a>]<br />
  101.                         <input type="text" name="subject" id="subject" size="25" /><br />
  102.                     </p>
  103.                     <p style="clear: both;">
  104.                         <label for="message">Message:</label><br />
  105.                         <textarea name="message" id="message" cols="60" rows="10"></textarea><br />
  106.                         <input type="submit" name="submit" value="Send" /> <input type="reset" name="reset" value="Reset" />
  107.                     </p>
  108.                 </form>
  109.             </div>
  110.             <p style="clear: both;"></p>
  111.         </div>
  112.         <div id="footer">
  113.             <p>Copyright © 2009 - 2010 <a href="http://www.wedevoy.com">Wedevoy.com</a></p>
  114.         </div>
  115.     </body>
  116. </html>

Is there any way that I could fix that? Thanks.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post May 20th, 2009, 8:32 am

Oh and $auth->get_user_list(); thing is...
Code: [ Select ]
function get_user_list($field)
{
    global $db;
   
    $userlist = $db->fetch_rowset("SELECT $field FROM " . USERS);
    $num_users = $db->num_rows("SELECT $field FROM " . USERS);
    $return_val = array();
   
    foreach($userlist as $user)
    {
        $return_val[] = $user[$field];
    }
   
    return $return_val;
}
  1. function get_user_list($field)
  2. {
  3.     global $db;
  4.    
  5.     $userlist = $db->fetch_rowset("SELECT $field FROM " . USERS);
  6.     $num_users = $db->num_rows("SELECT $field FROM " . USERS);
  7.     $return_val = array();
  8.    
  9.     foreach($userlist as $user)
  10.     {
  11.         $return_val[] = $user[$field];
  12.     }
  13.    
  14.     return $return_val;
  15. }
Looks like the problem is either from this function or the PHP in user_list.php...

[EDIT:] Fixed the problem... in the user_list.php I had the following PHP.
Code: [ Select ]
<?php
    require_once 'includes/globals.php';
   
    $userlist = $auth->get_user_list('username');
    $num_users = count($userlist);
   
    $n = 0;
    foreach($userlist as $user)
    {
        ++$n;
       
        echo "<a href=\"#\" onclick=\"insert_single('$user')\">$user</a>";
       
        if($n > 0 && $n < $num_users)
        {
            echo ",\n ";
        }
    }
?>
  1. <?php
  2.     require_once 'includes/globals.php';
  3.    
  4.     $userlist = $auth->get_user_list('username');
  5.     $num_users = count($userlist);
  6.    
  7.     $n = 0;
  8.     foreach($userlist as $user)
  9.     {
  10.         ++$n;
  11.        
  12.         echo "<a href=\"#\" onclick=\"insert_single('$user')\">$user</a>";
  13.        
  14.         if($n > 0 && $n < $num_users)
  15.         {
  16.             echo ",\n ";
  17.         }
  18.     }
  19. ?>

Changing that to:
Code: [ Select ]
<?php
    require_once 'includes/globals.php';
   
    $userlist = $auth->get_user_list('username');
    $num_users = count($userlist);
   
    $n = 0;
    foreach($userlist as $userss)
    {
        ++$n;
       
        echo "<a href=\"#\" onclick=\"insert_single('$userss')\">$userss</a>";
       
        if($n > 0 && $n < $num_users)
        {
            echo ",\n ";
        }
    }
?>
  1. <?php
  2.     require_once 'includes/globals.php';
  3.    
  4.     $userlist = $auth->get_user_list('username');
  5.     $num_users = count($userlist);
  6.    
  7.     $n = 0;
  8.     foreach($userlist as $userss)
  9.     {
  10.         ++$n;
  11.        
  12.         echo "<a href=\"#\" onclick=\"insert_single('$userss')\">$userss</a>";
  13.        
  14.         if($n > 0 && $n < $num_users)
  15.         {
  16.             echo ",\n ";
  17.         }
  18.     }
  19. ?>

Fixed the problem. For some reason the $user being named the same as the array $user in my $auth->get_user_list(); function were messing up the entire session on my site :shock:
"Bring forth therefore fruits meet for repentance:" Matthew 3:8

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 67 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.