Jump to content

klaroen

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Posts posted by klaroen

  1. yeah, that I know :p... I'll give another example:

    In a online game every player has his troops and has his attack power and defence power. Now, if I select the defence from the player that is logged in with query can I get the rank of his defence with a function?
    So his defence is like 5009 and there is only one player better with 6582 and a lot players are lower... Now, can I ask my database to count out for me that he's defence is the second highest?
    Or for other players how high their defence is (counted in places)...


    (get it?)
  2. Well, you have the file right, then you change your username and password in that file itself:
    The
    "
    $realUser = ""; // what you want your user name to be
    $realPass = ""; // what you want your password to be.
    "
    part.
    Then if you want to secure a page put this at the top of the page:

    include "config.php";
    authUser();

    That's all
  3. Imagine: I have a list of products and they all have their price.

    [code]
    <?php
       $player=$_SESSION['player'];
        $userstats="SELECT * from koc_products where username='$player'";
        $userstats2=mysql_query($userstats) or die("Error while connecting to database! Please report this to an admin!");
        $stat=mysql_fetch_array($userstats2);

       $ranking=[b]thecodeineed[/b]($stat[price]);

    print(" The product is our [b]?[/b] most expansive product!");

    [/code]

    So as you see the code I need should tell me how muchst he is in the list of most expensive products...


    Is that understandable?

    (ps: rank is the number of how high he is ( how muschest)(is that spelled like that?? )
  4. Oke this is the request:
    Is there a query function or code to do this:

    I have a database, and there are kind of diffrent number in it: 500 , 360 , 578, 9978, 7589, 125, 154, etc...

    Now when I select one of those, can I ask with a code with place he has from the top?
    So: I select the number 578 for example, can it tell me what 'rank' it has? so it should be 3th...

    Is there a code for that?
  5. oke I have some things:

    - try to use the same signs: one time you use "" for your content second time ''
    - You don't need to place a point ( . ) when inserting values!
    example:
    $query=mysql_query("INSERT into users(username,password,email) values('$RegName','$RegPass','$RegMail')");
  6. oke, first: this isn't such a big script but I'm not going to make it for you!
    Let's start:

    As first you need a database, in this database you put 'id, name, link, in, out'

    Then you make the main page, here you select the database stuff and use the 'while' thing to make a list of all the referers. You sort them on links "hits in-out" (that's the credit they have, so they can be in min...).
    Then in the while you pute their name with a link around it. This link must be [a href=\"http://www.yoursite.com/out.php?id=$id\" target=\"_blank\"]http://www.yoursite.com/out.php?id=$id[/a]. (The out page comes later)

    Then ofcource the referers must be able to make hits in:
    You give them a link: [a href=\"http://www.yoursite.com/in.php?id=theirid\" target=\"_blank\"]http://www.yoursite.com/in.php?id=theirid[/a]
    Then you make the in.php page:
    You can select their id from the url so you select his data from your database. Then you say update hits in + 1, oke :)
    If you want that they can only click once per IP you must put this in the If-Else structure...

    Then the out.php page.

    You select de data from the database with the id in the link. Then you update the out hits + 1. And you riderect the visitor to the url of the referer!!



    So that was all :p
    If you have questions you may ask them :D (if you are just a noob in php, I could understand that ... )

    Greets,
    klaroen
  7. not totally :p

    in login your 3th session register is spelled wrong :p :D

    phhh, f** it still not working!! Why not!!
    Well, let's try again:
    ____________________________________________

    menu.php (the login form)
    ---------------------------------
    [code]
    <form action="login.php" method="post">
    <table align="center" class="small" style="padding: 0px 0px 5px 0px;" width="130">
        <tr>
            <td align="center"><font color="black">Username:</font></td>
        </tr>
        <tr>
            <td align="center"><input class="login_input" type="text" name="LoginNaam" value=""></td>
        </tr>
        <tr>
            <td align="center"><font color="black">Email:</font></td>
        </tr>

        <tr>
            <td align="center"><input class="login_input" type="text" name="LoginMail" value=""></td>
        </tr>
        <tr>
            <td align="center"><font color="black">Password:</font></td>
        </tr>
        <tr>
            <td align="center"><input class="login_input" type="password" name="LoginPassword"></td>

        </tr>
        <tr>
            <td align="center" style="padding-top: 5px;"><input type="hidden" name="Submit" value="1"><input class="login_input" type="submit" value="Login" style="width: 50px;"></td>
        </tr>
    </table>
    </form>
    [/code]

    -------------------------------------
    -------------------------------------


    login.php
    --------------
    [code]
    <?php
    session_start();


    // connect to database.

    $DBHost = "localhost";
    $DBLogin = "klaroen_data";
    $DBPassword = "******";
    $DBDatabase = "klaroen_data";

    mysql_connect("$DBHost", "$DBLogin", "$DBPassword");
    @mysql_select_db("$DBDatabase");


    // if theres a post submit.

    if ($_POST(['Submit'] ) {


    $Query = mysql_query("SELECT * FROM koc_users WHERE username = '$LoginNaam' AND password = '$LoginPassword' AND email = '$LoginMail'");

    $Results = mysql_num_rows($Query);

    // if user exists goto base.php

    if ($Results == '1') {

    session_register('email');
    session_register('name');
    session_register('password');

    header ("Location: base.php");



    }else{

    header ("Location: wronglogin.php");

    }


    }
    ?>
    [/code]

    ---------------------------
    ---------------------------


    base.php
    -------------
    [code]
    <?php  
    session_start();

    if ((! $_SESSION['username'] )&& (! $_SESSION['password'])) {
    ?>

    <!-- *************** -->
    <!-- Check the login -->
    <!-- And else...     -->
    <!-- *************** -->
    <?php
    include("connect.php");
    ?>
    <?php
    $query = "SELECT * FROM koc_users WHERE username = '".$_SESSION['username']."' and password='".$_SESSION['password']."' ";
    $st=mysql_query($query);
    while($row=mysql_fetch_assoc($st)){
    ?>
                    <table width="100%">
                    <tr>
                    <td width="50%" valign="top" style="padding-right: 25px;">
                    <table class="table_lines" width="100%" cellspacing="0" cellpadding="6" border="0">
                    <tr>
                    <th colspan="2" align="center">User Info</th>
                    </tr>
                    <tr>
                    <td><b>Name</b>
                    </td>
                    <td><? echo $row['username']; ?></td>
                    </tr>
    </table>
    </td>
    </tr>
    </table>
    <? } ?>


    <?php

    //if not logged in goto correct page.

    }else{

    header("location:  mustlogin.php ");

    }

    ?>
    [/code]
    -------------------------------------


    If we can't solve this in the next 30 min, I think I'll quite for this evening (22:26 here)
    Fingers Crosses! :p
    klaroen
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.