need help with a bug in php

Page 1 of 2 12 LastLast
Results 1 to 25 of 34
  1. #1
    Member s1lVa is offline
    MemberRank
    Feb 2004 Join Date
    92Posts

    need help with a bug in php

    im using a ftp server, and im making a automatic register script.
    the php code will store the info in a users.ini file, but i have a problem with the code

    the error is that it doesnt add the lines in the users.ini file, but it overwrites the existing lines, and because of that it deletes the others users. what is wrong?


    <?
    $dir = 'C:\\Program Files\\BPFTP Server\';
    if(!$_POST){
    echo '<form action='.$_SERVER['PHP_SELF'].' method=post>
    <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td align="center" valign="middle"><strong>vShare Account Creation </strong></td>
    </tr>
    <tr>
    <td><table width="300" border="0" cellspacing="0" cellpadding="3">
    <tr>
    <td>Account-Name:</td>
    <td><input name=account type=text maxlength=12></td>
    </tr>
    <tr>
    <td>Password:</td>
    <td><input name=password type=password maxlength=12></td>
    </tr>
    <tr>
    <td>Password(Again):</td>
    <td><input name=confirm type=password maxlength=12></td>
    </tr>
    <tr>
    <td>E-Mail:</td>
    <td><input name=email type=text>
    </td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td align="center" valign="middle"><input name=submit type=submit value=Submit account></td>
    </tr>
    </table>
    ';
    **
    else{
    $account = $_POST['account'];
    $confirm = $_POST['confirm'];
    $password = $_POST['password'];
    $email = $_POST['email'];
    $filename = $dir . 'users1.ini';
    if($account == '') { echo 'Account creation failed. Please fill out all fields.'; **
    elseif(file_exists($account)) { echo 'Account creation failed. Account name already exists.';**
    elseif($email == '') { echo 'Your e-mail is required.';**
    elseif(!ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$", $email)){ echo 'Please enter a valid e-mail.'; **
    elseif($password != $confirm) { echo 'Password you selected does not match with conformation.';**
    else{
    $fp = fopen($filename, 'w+');
    $string = '

    [vS '.$account.']
    Login='.$account.'
    Pass='.$password.'
    Home-Ip=-= All IP Homes =-
    RelativePath=1
    TimeOut=600
    EnableMaxConPerIP=1
    MaxConPerIp=1
    EnableMaxUsers=1
    MaxUsers=1
    RatioEnabled=1
    RatioMethod=2
    RatioUp=1
    RatioDown=4
    RatioCredit=500000
    MaxSpeedRcv=512
    MaxSpeedSnd=512
    QuotaCurrent=0
    QuotaMax=0
    Dir0=C:\Documents and Settings\s1lVa\My Documents\My Pictures\
    Attr0=R----LS-
    Dir1=C:\Documents and Settings\s1lVa\My Documents\My Pictures\+03+ Upload\
    Attr1=RW--MLS-
    Info_Email='.$email.'
    Stat_Login=0
    Stat_LastLogin=0
    Stat_LastIP=Unknown
    Stat_KBUp=0
    Stat_KBDown=0
    Stat_FilesUp=0
    Stat_FilesDown=0
    Stat_FailedUp=0
    Stat_FailedDown=0

    ';
    $write = fwrite($fp, $string);
    fclose($fp);
    echo 'Account created successfully, You may now log in with your vShare account!';
    **
    **
    ?>


  2. #2
    Sorcerer Supreme Dragon is offline
    Member +Rank
    Feb 2003 Join Date
    Your local parkLocation
    460Posts
    lol , ur mistake is a classic 1 and actually pretty simple, once u get it ...

    ur using the command :

    PHP Code:
    $fp fopen($filename'w+'); 
    now... the "w+" or also "w" command specifies that your filepointer is being put in the beginning of the file and u overwrite everything in it.

    the sollution is using the "a" or "a+" command.


    this one puts the filepointer on the end of the file and then adds everything u wanna add (it also creates the file if it doesn't already exist ) .


    Hope i ve helped a bit...

    Fear the Dragon...
    ~xxx~
    Last edited by Dragon; 22-03-04 at 12:45 PM.

  3. #3
    The Unbeatable GohanSSJ is offline
    LegendRank
    Sep 2003 Join Date
    The NetherlandsLocation
    15,678Posts
    Go girl! :hail:

  4. #4
    8694 ~ Legend 8694 is offline
    Grand MasterRank
    Dec 2003 Join Date
    United KingdomLocation
    624Posts
    Lol i wouldnt of had a clue :p
    Very pro of u (^_^)

  5. #5
    Grand Master NeoSparky is offline
    Grand MasterRank
    Nov 2003 Join Date
    BelgiumLocation
    2,117Posts
    Originally posted by Dragon
    lol , ur mistake is a classic 1 and actually pretty simple, once u get it ...

    ur using the command :

    PHP Code:
    $fp fopen($filename'w+'); 
    now... the "w+" or also "w" command specifies that your filepointer is being put in the beginning of the file and u overwrite everything in it.

    the sollution is using the "a" or "a+" command.


    this one puts the filepointer on the end of the file and then adds everything u wanna add (it also creates the file if it doesn't already exist ) .


    Hope i ve helped a bit...

    Fear the Dragon...
    ~xxx~
    *biiiig frown*

  6. #6
    Sorcerer Supreme Dragon is offline
    Member +Rank
    Feb 2003 Join Date
    Your local parkLocation
    460Posts
    Originally posted by NeoSparky
    *biiiig frown*

    go play a bit VB and leave the bigger things like PHP and CISCO to big girls :tp:

  7. #7
    Member s1lVa is offline
    MemberRank
    Feb 2004 Join Date
    92Posts
    thx dude, ill try it out later tonight.. gotta go to work now

  8. #8
    Grand Master NeoSparky is offline
    Grand MasterRank
    Nov 2003 Join Date
    BelgiumLocation
    2,117Posts
    Originally posted by Dragon
    go play a bit VB and leave the bigger things like PHP and CISCO to big girls :tp:
    pfffrt...

    Originally posted by s1lVa
    thx dude


  9. #9
    Sorcerer Supreme Dragon is offline
    Member +Rank
    Feb 2003 Join Date
    Your local parkLocation
    460Posts
    Originally posted by s1lVa
    thx dude, ill try it out later tonight.. gotta go to work now

    dude 0.o

    hmmmm... i think u ve gotta get ur sexes straight :tp:

    Fear the Dragon...
    ~xxx~
    Last edited by Dragon; 22-03-04 at 02:19 PM.

  10. #10
    Grand Master NeoSparky is offline
    Grand MasterRank
    Nov 2003 Join Date
    BelgiumLocation
    2,117Posts
    Originally posted by Dragon
    dude 0.o

    hmmmm... i think u ve gotta get ur sexes straight :tp:
    i dont blame him for mixing you up

  11. #11
    Member s1lVa is offline
    MemberRank
    Feb 2004 Join Date
    92Posts
    look dudes, everyone is a dude for me, even girls

  12. #12
    Sorcerer Supreme Dragon is offline
    Member +Rank
    Feb 2003 Join Date
    Your local parkLocation
    460Posts
    Originally posted by NeoSparky
    i dont blame him for mixing you up
    damn u cross-eyed bitch

    :tp:

    Fear the Dragon...
    ~xxx~

  13. #13
    Grand Master NeoSparky is offline
    Grand MasterRank
    Nov 2003 Join Date
    BelgiumLocation
    2,117Posts
    Originally posted by Dragon
    damn u cross-eyed bitch

    :tp:
    wub you too :)

  14. #14
    Sorcerer Supreme Dragon is offline
    Member +Rank
    Feb 2003 Join Date
    Your local parkLocation
    460Posts
    yeah yeah...


    good girl...
    have a cookie...



    fear the dragon...
    ~xxx~
    Attached Images Attached Images

  15. #15
    Grand Master NeoSparky is offline
    Grand MasterRank
    Nov 2003 Join Date
    BelgiumLocation
    2,117Posts
    *frown*
    Attached Images Attached Images

  16. #16
    Member s1lVa is offline
    MemberRank
    Feb 2004 Join Date
    92Posts
    Originally posted by NeoSparky
    *frown*
    lol!! :rofl:

  17. #17
    Everybody loves DTB DonTonberry is offline
    LegendRank
    Feb 2003 Join Date
    AwesomevilleLocation
    6,161Posts
    Unleash The Claws Ladies


    Originally posted by Dragon
    damn u cross-eyed bitch

    :tp:

    Fear the Dragon...
    ~xxx~
    Nothing Wrong With Being Cross Eye'd Is There?

    :cry:



    *I'm Cross/Boggle Eyed BTW*
    Last edited by DonTonberry; 22-03-04 at 03:07 PM.

  18. #18
    *still exists* Solares is offline
    Grand MasterRank
    Feb 2003 Join Date
    LeicesterLocation
    4,381Posts
    *sigh* im a full time web designer n i wouldent have even had a clue as to how to fix that problem :(. Come to think of it.... neither could my boss :cry:. That haveing been said.... i do like the simple HTML pages that i make useing all my design skills n stuff :) still look very porfessional :D.

    I know your both allot better than me at that sort of thing... but please dont take the piss coz ive just said all that :(.

  19. #19
    Everybody loves DTB DonTonberry is offline
    LegendRank
    Feb 2003 Join Date
    AwesomevilleLocation
    6,161Posts
    Originally posted by Solares
    *sigh* im a full time web designer n i wouldent have even had a clue as to how to fix that problem :(. Come to think of it.... neither could my boss :cry:. That haveing been said.... i do like the simple HTML pages that i make useing all my design skills n stuff :) still look very porfessional :D.

    I know your both allot better than me at that sort of thing... but please dont take the piss coz ive just said all that :(.

    *Takes The Piss*


    PHP Is Hard, Why Couldnt They Just Use VB To Do PHP's Job, Coz PHP Sucks And VB Rules!

  20. #20
    Sorcerer Supreme Dragon is offline
    Member +Rank
    Feb 2003 Join Date
    Your local parkLocation
    460Posts
    because php is better ???

    :tp:

    it rules once u get the hang of it ;)

  21. #21
    Grand Master MasterD is offline
    LegendRank
    Feb 2003 Join Date
    Manchester UKLocation
    2,391Posts
    argh Neo u doin VB lol i did it for about a month and dropped out zzzzzzzzzzzzZZZZZZZZZzzzzzzzzzzzzzzzzzzZZZZZZZZZzzzzzzzzzz'ing

  22. #22
    Sorcerer Supreme L3thal is offline
    Member +Rank
    Feb 2004 Join Date
    newcastleLocation
    314Posts
    whats the diff between php and vb then? :confused:

  23. #23
    Sorcerer Supreme Dragon is offline
    Member +Rank
    Feb 2003 Join Date
    Your local parkLocation
    460Posts
    vb sux , php rules

    php = OO programming/scripting
    vb = playing around/sequencial progging

  24. #24
    Everybody loves DTB DonTonberry is offline
    LegendRank
    Feb 2003 Join Date
    AwesomevilleLocation
    6,161Posts
    Originally posted by Dragon
    vb sux , php rules

    php = OO programming/scripting
    vb = playing around/sequencial progging

    VB Doesnt Suck, But Yeah Its A Playing Around Language :)

    php Stands For Programming Hyper Poop

  25. #25
    Sorcerer Supreme L3thal is offline
    Member +Rank
    Feb 2004 Join Date
    newcastleLocation
    314Posts
    Originally posted by DonTonberry
    VB Doesnt Suck, But Yeah Its A Playing Around Language :)

    php Stands For Programming Hyper Poop
    lol, i might try VB just to mess around then try the 1337 programming



Page 1 of 2 12 LastLast

Advertisement