I have a problem in my cryption function.I made an cryption function(actually found) which changes the numbers and letters in your password like this and in my registration form i included it and it leave blank the password field in my txt file which that php file write on.(sphereacct.scp)
Cryption Function
function password_to_crypted($pass)
{
$tbl_lower = "txnjwiklcvzbgerpmdfqhsauoy";
$tbl_upper = "ZOYRUBTJKIPADEMSFHXWLNVQGC";
$tbl_num = "7523689401";
$crypted = "";
$ord_a_1 = ord('a');
$ord_z_1 = ord('z');
$ord_a_2 = ord('A');
$ord_z_2 = ord('Z');
$ord_0 = ord('0');
$ord_9 = ord('9');
for ($i = 0; $i < strlen($pass); $i++)
{
$c = ord($pass[$i]);
if ($c >= $ord_a_1 && $c <= $ord_z_1)
$crypted .= $tbl_lower[$c - $ord_a_1];
else if ($c >= $ord_a_2 && $c <= $ord_z_2)
$crypted .= $tbl_upper[$c - $ord_a_2];
else if ($c >= $ord_0 && $c <= $ord_9)
$crypted .= $tbl_num[$c - $ord_0];
else
$crypted .= $pass[$i];
}
return $crypted;
}
HTML
<html>
<body bgcolor="#FFFFFF" text="#000000">
<form action="kayit.php" method="get">
<b>Kullanici Adiniz:</b><input type="text" name="u_name" size="20"><br>
<b>Sifreniz:</b><input type="password" name="pass" size="20"><br>
<b>Email Adresiniz:</b><input type="text" name="mail" size="20"><br>
<input type="submit" value=" Kayit ">
</form>
</body>
</html>
PHP
<?
@mysql_connect("localhost", "dakkar", "1234567")
or die("Cannot connect to database!");
@mysql_select_db("test")
or die("Cannot connect to database");
$sql = "SELECT count(*) FROM kayit WHERE username = '".$_GET['u_name']."'";
$res = mysql_query($sql) OR die(mysql_error());
$row = mysql_fetch_row($res);
if($row[0] == 0) {
if (($u_name !== "") && ($pass !== "") && ($mail !== "")) {
if (ereg("@",$mail) && ereg(".",$mail)) {
if (eregi("remote",$u_name) || eregi("admin",$u_name) || eregi("syl",$u_name)) {
echo "<center><b>This nick is forbidden.</b></center>";
} else {
@("insert into kayit values('$u_name','$pass','$mail')");
echo "<center><b>Your data has benn inserted into database.</b></center>";
$acc_giris = (fopen("./sphereacct.scp","a"));
include ("./password.php");
$yeni_metin = "[$u_name]\r\nPASSWORD=$crypted\r\nPLEVEL=1\r\nPRIV=00000\r\n \r\n";
fwrite($acc_giris, $yeni_metin);
fclose($acc_giris);
}
} else {
echo "<center><b>Please enter a valid email adres</b></center>.";
}
} else {
echo "<center><b>Please fill all the blanks";
}
} else {
echo "<center><b>The username you wanted is already registered.</b></center>";
}
?>