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 12 of 12

Thread: Another Problem

  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Another Problem

    The problem is I can signup more then once, I don't know what is wrong in my coding but if their is more then one ip in the users it shouldn't let them signup. Also, if I goto that page, even without hitting submit it says "You can not make more then one account!".

    Please help




    Code:
    <?php
    $title = "Signup";
    include("top.php");
    $IP = $_SERVER['REMOTE_ADDR'];
    ?>
    
    
    <div id="content">
    <span>Signup</span>
    
    
    <p>
    <form method="POST" action="signup.php?action=signup">
                 Username:<br> <input type="text" name="username" size="20" maxlength="15"><br>
                 Password:<br> <input type="password" name="password" size="20" maxlength="15"><br>
          Verify Password:<br> <input type="password" name="verpassword" size="20" maxlength="15"><br>
                    Email:<br> <input type="text" name="email" size="20" maxlength="25"><br><br>
    
    
    Note: Your ip will be logged so please do not make multiple accounts<br><br>
    <input type="submit" name="action" value="Signup"></form>
    
    
    <?php
    $ipcheck = mysql_query("select * from users where IP='$IP'");
    IF(@mysql_numrows($ipcheck) > 0){
    $ipused = yes;
    }else{
    $ipused = no;
    }
    
    
    
    
    
    IF ($action == "Signup" && $ipused == "no"){
    $userupdate = mysql_query("INSERT INTO users (id, username, email, password, status, ipaddress, age) VALUES ('', '$username', '$email', '$password', '', '$IP', '')");
    echo "Thank you for signing up.";
    }else{
    echo "You can not make more then one account!";
    }
    ?>
    
    
    
    
    </div>
    
    
    <?php
    include("bottom.php");
    ?>

  • #2
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Validating with IP is meaningless as anyone could go to a internet cafe, freind, connect via modem, have a dynbamic IP or use a proxy.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    You cannot trust that remote_addr is accurate, dialup will always change, and if you have a dynamic high speed connection, your ip will also change.

    The only way to control this is to disallow users from signing up more than once, meaning the user must be logged in to control that they do not create more than one account.
    But there is no other accurate way of controlling this.

  • #4
    New Coder
    Join Date
    Jan 2005
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you guys just help me get this working please?? I am gonna try this for now because I am just making it. I will worry about that situation later.

  • #5
    Regular Coder
    Join Date
    Mar 2005
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well first off, you input an age into the query, but you don't have an age section in the form, might want to fix that first.
    PHP Code:
    $userupdate mysql_query("INSERT INTO users (id, username, email, password, status, ipaddress, age) VALUES ('', '$username', '$email', '$password', '', '$IP', '')"); 
    unless you just have the age auto_increment which just doesn't make any sense to me

  • #6
    New Coder
    Join Date
    Jan 2005
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do not have a status one etheir, it is default set to 0 and my status one is default set to member

  • #7
    Regular Coder
    Join Date
    Oct 2004
    Posts
    364
    Thanks
    0
    Thanked 18 Times in 18 Posts
    You have (note "signup")
    Code:
    <form method="POST" action="signup.php?action=signup">
    But then you have (note Signup)
    PHP Code:
    IF ($action == "Signup" && $ipused == "no"){ 
    PHP is case sensitive.

    EDIT: And shouldn't it be $_GET['action'] ?
    EDIT2: or maybe $_POST['action']?
    Last edited by schleppel; 06-16-2005 at 06:03 PM.

  • #8
    New Coder
    Join Date
    Jan 2005
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, that was for the button the submit button and the value = Signup...

  • #9
    New Coder
    Join Date
    Jan 2005
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks

  • #10
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    The submit button will be $_POST['action'] as that's what you've named the button..

  • #11
    Regular Coder
    Join Date
    Apr 2005
    Posts
    388
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I agree $action isn't Signup so you will never execute your query.

  • #12
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    <?php
    $title 
    "Signup";
    include(
    "top.php");
    $IP $_SERVER['REMOTE_ADDR'];
    ?>


    <div id="content">
    <span>Signup</span>


    <p>
    <form method="POST" action="signup.php?action=signup">
                 Username:<br> <input type="text" name="username" size="20" maxlength="15"><br>
                 Password:<br> <input type="password" name="password" size="20" maxlength="15"><br>
          Verify Password:<br> <input type="password" name="verpassword" size="20" maxlength="15"><br>
                    Email:<br> <input type="text" name="email" size="20" maxlength="25"><br><br>


    Note: Your ip will be logged so please do not make multiple accounts<br><br>
    <input type="submit" name="action" value="Signup"></form>


    <?php
    if(isset($_POST['action'])){
        
    $ipcheck mysql_query("SELECT IP FROM users WHERE IP='$IP'");
        IF(@
    mysql_num_rows($ipcheck) > 0){

            echo 
    "You can not make more then one account!";

        }else{
                
    $userupdate mysql_query("INSERT INTO users (id, username, email, password, status, ipaddress, age) VALUES ('',$_POST['username'],$_POST['email'],$_POST['password'],'',$IP,'')");
                echo 
    "Thank you for signing up.";
            }
        }
    }
    ?>

    </div>

    <?php
    include("bottom.php");
    ?>
    Still not 100% efficient, but it's been cleaned up a bit
    Last edited by Nightfire; 06-17-2005 at 01:46 AM.


  •  

    Posting Permissions

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