Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

need help with a bug in php

Newbie Spellweaver
Joined
Feb 24, 2004
Messages
92
Reaction score
0
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!';
**
**
?>
 
Elite Diviner
Joined
Feb 18, 2003
Messages
405
Reaction score
8
lol , ur mistake is a classic 1 and actually pretty simple, once u get it ...

ur using the command :

PHP:
$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:
Custom Title Activated
Loyal Member
Joined
Nov 19, 2003
Messages
1,985
Reaction score
4
Dragon said:
lol , ur mistake is a classic 1 and actually pretty simple, once u get it ...

ur using the command :

PHP:
$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*
 
Elite Diviner
Joined
Feb 18, 2003
Messages
405
Reaction score
8
s1lVa said:
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:
Elite Diviner
Joined
Feb 18, 2003
Messages
405
Reaction score
8
yeah yeah...


good girl...
have a cookie...



fear the dragon...
~xxx~
 

Attachments

You must be registered for see attachments list
*still exists*
Loyal Member
Joined
Feb 18, 2003
Messages
3,749
Reaction score
17
*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 :(.
 
Everybody loves DTB
Legend
Joined
Feb 18, 2003
Messages
5,301
Reaction score
248
Solares said:
*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!
 
Back
Top