PHP not creating file.

Posted on 16th Feb 2014 by admin

Its supposed to create a .ini file in the /scriptfiles/users/ with the name they entered into the field then its supposed to create a password in the file in md5 encryption like this "password=32jknfdjkb324" like that but it doesn't create the file?, Heres my code.

Code: [Select]<center>
<form method=post action=register.php?action=register name=s>
<table>
<h1>Register on our SA-MP Server.</h1>
<tr><td>Username:</td><td><input type=text name=username></td></tr>
<tr><td>Password:</td><td><input type=password name=password></td></tr>
<tr><td colspan=2 align=center><input type=submit value=Register></td></tr>
</table>
</form>
</center>
<?php
if ($action == register) {
//cAccounts
//By Chris
//Register accounts and login on websites.

$ftp_host = "randomhostname"; //put the ip / hostname to your ftp here
$ftp_user = "randomuser"; //put your login here
$ftp_pass = "password"; //put your password here
$username = $_POST['username'];
$password = md5($_POST['password']);

$con = ftp_connect($ftp_host) or die("Error: Could not connect to FTP, Check FTP Settings.");
ftp_login($con, $ftp_user, $ftp_pass);

if (file_exists($username)) {
echo "This username already exists!, Please try another.";
} else {
$createfile = "scriptfilesusers$username.ini";
$wrightfile = fopen($createfile, 'w') or die("Error: Cannot create file.");
$wpass = "password=$password";
fwrite($wrightfile, $wpass);
fclose($wrightfile);
}



ftp_close($con);
}

?>

Other forums