PHP Tutorials : How to create Member List In PHP & MYSQL ?

Discussion in 'PHP' started by mizuki, May 11, 2007.

  1. #1
    In this tutorials.I teach you "how to create member list in PHP with mysql.This Source code has been writen form T4VN Team. so, if you want to develop it, please contact us. Thanks for your interested in this code.


    Step 1 : Create database with information

    <? 
    CREATE TABLE `user` ( 
    
      `user_id` int(10) unsigned NOT NULL auto_increment, 
    
      `username` varchar(150) NOT NULL default '', 
    
      `password` varchar(150) NOT NULL default '', 
    
      `email` varchar(255) NOT NULL default '', 
    
      PRIMARY KEY (`user_id`) 
    )  ; 
    ?>
    PHP:
    Step 2 : As I have some data,example :
    <? 
    
    INSERT INTO `user` VALUES (1, 'admin', '12345', 'admin@a.com'); 
    
    INSERT INTO `user` VALUES (2, 'jacky', '1234578910', 'jacky@y.com'); 
    
    INSERT INTO `user` VALUES (3, 'mizuki', 'abcd', 'mi@a.com'); 
    
    ?>
    PHP:
    Now,how to list all of member in this table ?.

    Step 3: create listmember.php with code below

    <HTML> 
    
    <HEAD> 
    
    <meta http-equiv="Content-Language" content="en-us"> 
    
    <TITLE>This is Example</TITLE></HEAD> 
    
    <body> 
    
                <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#77a7ad  
    
                cellSpacing=1 cellPadding=1 width="100%" bgColor=#ffffff border=1> 
    
            <tr> 
    
                <td width="37" align="center" ><font face="Tahoma" size="2"><b>STT</b></font></td> 
    
                <td align="center" ><font face="Tahoma" size="2"><b>Username</b></font></td> 
    
                <td align="center" ><font face="Tahoma" size="2"><b>Email</b></font></td> 
    
                        </tr> 
    
    <? 
    
    $ds="select * from user order by user_id "; 
    
    $rs=mysql_query($ds,$connect); 
    
    if(mysql_num_rows($rs)!= "") 
    
    { 
    
        $stt=0; 
    
        while($row=mysql_fetch_array($rs)) 
    
        { 
    
            $stt++; 
    
    ?> 
    
            <tr> 
    
                <td width="37" align="center"><font face="Tahoma" size="2"><?=$stt?></font></td> 
    
                <td align="center"><font face="Tahoma" size="2"><?=$row["dn_username"]?></font></td> 
    
                <td align="center"><font face="Tahoma" size="2"><?=$row["dn_email"]?></font></td> 
    
    
    
    
    
            </tr> 
    
            <? 
    
        } 
    
    ?> 
    
        </table> 
    
    </body> 
    
    </html>
    
    
    PHP:
    Now,you're done

    All information you can find here:

    http://www.t4vn.net/tutorials/showtutorials/How-to-create-Member-List-In-PHP.html

    Good lucks with your practice.
     
    mizuki, May 11, 2007 IP
  2. mikey1090

    mikey1090 Moderator Staff

    Messages:
    15,869
    Likes Received:
    1,055
    Best Answers:
    0
    Trophy Points:
    445
    Digital Goods:
    2
    #2
    not going to validate output? htmlentities() i think it is...
     
    mikey1090, May 12, 2007 IP
  3. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This post seems a bit spammy.. and the tutorial itself isn't that great.

    As mentioned above you're not validating the output (though assuming you're validating the input of the users shouldn't need to, but still good practice).

    The code itself is just sloppy.. the nesting isn't done properly, you're calling variables you haven't declared ($connected, which should be the mysql_connect() chunk) etc.
     
    CodyRo, May 12, 2007 IP
  4. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #4
    agree with CodyRo, missing if } , missing connect declaration and mysql_connect method call.
     
    gibex, May 12, 2007 IP