If anyone knows PHP, please help me with my script, i would really appreciate it!!!

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
I have a problem with the script i made :( I get a parse error. I seem to have closed all my brackets, and still i get the error. Could someone look over the script and tell me what i did wrong? THANKS!!!!!

<?

$file_directory = 'c:\filedir';
$file_contents = file("$file_directory\\filedir.INI");
sort($file_contents);
$sizeof = count($file_contents);

function randomPassword () {
$length ="8";
$possible = '123456789' .
'ABCDEFGHJKLMNPQRSTUVWXYZ';
$pwd ="";
while (pwdlen($pwd) < $length) {
$pwd.=substr($possible, (rand() % pwdlen($possible)),1);
}

}





if(!file_exists("c:\signup\$email"))
{
print("<b>$email</b> already exists, please choose another.");


}elseif (!file_exists("c:\www\members\$user"))
{
print("<b>$user</b> already exists, please choose another.");


} else {
if(mkdir("c:\signup\\$email", 0707))
if(mkdir("c:\www\members\\$user", 0707))
if($SERVU= fopen("$file_directory\\filedir.INI", "a"))
if($userlist = fopen("c:\www\dittohost\users.html", "a"))
if($accounts = fopen("c:\MemberAccounts\members.txt", "a"))




fputs($SERVU,
"

Password=$pwd
");
fclose($SERVU;




fputs($userlist,
"
<b>[$user]</b>
http://www.dittohost.com/members//$user
E-mail Address: $email
Name: $name
Secret question: $question
Secret answer: $answer
Heard about dittohost from: $dittohost
Details: $details
ICQ: $icq
");
fclose($userlist);



fputs($accounts,
"
USER=$user
Password=$pwd
E-mail Address: $email
Name: $name
Secret question: $question
Secret answer: $answer
Heard about dittohost from: $dittohost
Details: $details
ICQ: $icq

");
fclose($accounts);

if(mail("$email", "Account Signup Information", "Thanks for choosing dittohost. The signup password is as follows: $pwd Dont forget it.
", "From: [email]Administrator@dittohost.com[/email]\n"))
print("Successfully added <b>$user</b> to database, your password has been emailed to you.");

}

?>
 

MereMortal

Golden Member
Oct 16, 2000
1,919
2
81
This line? Needs a closing parenthesis.
fclose($SERVU;



Also you might want to look into using atoms for string manipulations, e.g. [1-9A-Z] instead of '123456789'.'ABCDEFGHJKLMNPQRSTUVWXYZ'
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
Now can someone help me with the elseif and all that?

its not doing what i wanted, i wanted it to check like this:


if(!file_exists("c:\signup\$email")) //if it exists, print this, if not, continue
{
print("<b>$email</b> already exists, please choose another.");


}elseif (!file_exists("c:\www\members\$user"))//if it exists, print this, if not, continue
{
print("<b>$user</b> already exists, please choose another.");


} else { //make the user


But, it prints the email no matter what. Could someone help me? Thanks!
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
hmmm..something is bothering me with this line..

if (!file_exists("c:\signup\$email"))



you want to print out a message if the email exists on file, so why do you want to negate the return of file_exists() function?
file_exists() returns true if the file exists, or false otherwise. so, if you negate that your message will be printed if the file doesn't exist.


try this:

if (($e_temp=file_exists("c:\signup\$email")) || ($u_temp=file_exists("c:\www\members\$user")))
{
if ($e_temp) {
print("$email exists");
} else { print("$user exists"); }

} else { 'create user' }

 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
I tried it, it almost works!

But now, when the email doesnt exist, there is no problems, but if it does, I get errors like mkdir failed, that means its still executing the rest of the script! :(

Can anyone find a solution?

please help me!!!
thanks!
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
hmm.. you may want to check your user creation lines..



<<
else {
if(mkdir("c:\signup\\$email", 0707))
if(mkdir("c:\www\members\\$user", 0707))
if($SERVU= fopen("$file_directory\\filedir.INI", "a"))
if($userlist = fopen("c:\www\dittohost\users.html", "a"))
if($accounts = fopen("c:\MemberAccounts\members.txt", "a"))
>>


it doesn't make much sense to me. are you trying to create a directory or a file? mkdir() is a directory creation function. let me know what you want to do here exactly.

ok, i just read the rest of your codes. you don't need the first two lines, that's what causing your error.
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
i want to do both, i want to make 2 directorys (the email so there is only one email per user type thing, and the user, so there only one username thats the same) then i want to write the info the 3 files, the html file, the INI file and the txt file, and i want a random password, which will be sent to the email address!

thats about it! :)
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
ok, i am totally dazzed and didn't read your message carefully. it's only causing problem when the email exists, right? well, those lines shouldn't even be executed if the email or the username exist. check your IF statement again and make sure that the ELSE is the 'else' part of the IF statement.
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
I copied it directly off the site and added it, i still got the MkDir error and all that.

any sugestions?
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
can you post the current script that is causing the error? it would help cuz i have no idea how it looks from your original post now.
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
This is what I currently have, i hope you guys can help!

If you guys find the problem, please post it, i have to leave now, i will only be on tomorrow.

Thanks for all your help, i really appreciate it!



<?
$file_directory = 'c:\filedir';
$file_contents = file("$file_directory\\filedir.INI");
sort($file_contents);
$sizeof = count($file_contents);

function randomPassword () {
$length ="8";
$possible = '123456789' .
'ABCDEFGHJKLMNPQRSTUVWXYZ';
$pass ="";
while (passlen($pass) < $length) {
$pass.=substr($possible, (rand() % passlen($possible)),1);
}
$pass = ($pwd);




if (($e_temp=file_exists("c:\signup\$email")) || ($u_temp=file_exists("c:\www\members\$user")))
{
if ($e_temp) {
print("<b>$email</b> exists, please enter your valid email address, it will be used for sending your password");
} else { print("$user exists, please choose another"); }

} else {
if(mkdir("c:\signup\\$email", 0707))
if(mkdir("c:\www\members\\$user", 0707))
if($SERVU= fopen("$file_directory\\fileldir.INI", "a"))
if($userlist = fopen("c:\www\dittohost\users.html", "a"))
if($accounts = fopen("c:\MemberAccounts\members.txt", "a"))




fputs($SERVU,
"

Password=$pwd
");
fclose($SERVU);




fputs($userlist,
"
<b>[$user]</b>
http://www.dittohost.com/members//$user
E-mail Address: $email
Name: $name
Secret question: $question
Secret answer: $answer
Heard about dittohost from: $dittohost
Details: $details
ICQ: $icq
");
fclose($userlist);



fputs($accounts,
"
USER=$user
Password=$pwd
ChangePassword=NO
E-mail Address: $email
Name: $name</p>
Secret question: $question
Secret answer: $answer
Heard about dittohost from: $dittohost
Details: $details
ICQ: $icq

");
fclose($accounts);

if(mail("$email", "Account Signup Information", "Thanks for choosing dittohost. The signup password is as follows: $pwd Dont forget it.
", "From: [email]Administrator@dittohost.com[/email]\n"))
print("Successfully added <b>$user</b> to database, your password has been emailed to you.");
}
}
?>
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
are you running this on a Windows platform? I don't think the chmod permissions style is supported on Windows file system. May want to change the line:

mkdir("c:\signup\$user", 0707)

to

mkdir("c:\signup\$user", 0777)
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
I ended random password at the complete end. Because it wouldnt read the password before for some reason, so i tried making it go further, so it might read it anyways, it was just a test.

I tried it out again, but I got 3 underfined variables (pwd) and then it said sucessfully added. it is still exectuting the rest of the script, but i dont want it to!


hope you guys can find a solution!


Edit: I now get a "server error" on the last line if the email DOESNT exist. But now, if it does, then i still get all the MkDir errors :(
 

WarDemon666

Platinum Member
Nov 28, 2000
2,224
0
0
This is what i currently have as the IF and ELSE part, i know that this is the error, because even if the user exists, it still continues the rest of the create user part.....

Could someone read it and tell me what is wrong? when i execute it and the email exists, i get a MkDir error, and a whole bunch of undefined variables. But when nothing exists and i create it, it works perfectly.

Thanks in advance!





if (($e_temp=file_exists("c:\signup\$email")) || ($u_temp=file_exists("c:\www\members\$user")))
{
if ($e_temp) {
print("<b>$email</b> exists, please enter your valid email address, it will be used for sending your password");
} else { print("$user exists, please choose another"); }

} else {
if(mkdir("c:\signup\\$email", 0777))
if(mkdir("c:\www\members\\$user", 0777))
if($SERVU= fopen("$file_directory\\SERV-U.INI", "a"))
if($userlist = fopen("c:\www\dittohost\users.html", "a"))
if($accounts = fopen("c:\MemberAccounts\members.txt", "a"))
bla bla bla