You are here: Php signup problem « PHP Programming Language « IT news, forums, messages
Php signup problem

Posted by jon on 02/02/07 18:19

Hey, i've been trying to create a signup page that asks for a
username, password and then to confirm the password. It is suppose to
check how long both of them are, and if the passwords line up, that
went well, but i can't make it check to see if it is being used by
someone else. heres the script, good luck.

/
*************************signup.html*******************************************************************/
<fieldset>
<form method="POST"action="signup.php">
Username: <input type="text"name="user"/><br/>
Password: <input type="password"name="passa"/><br/>
Confirm password: <input type="password"name="passb"/><br/>
<input type="submit"value="Submit"/>
</form>
</fieldset>
/
********************************************************************************************************/


/
****************signup.php*****************************************************************************/
<?php
/********Get info********/
$user = $_POST["user"];
$pass_a = $_POST["passa"];
$pass_b = $_POST["passb"];
/*************************^^^^^^^^^^^*************************/


/******Key varibles******/
$flag = "OK";
$msg = "";
$num = "0";
/*************************^^^^^^^^^^^*************************/


/********Validate Form***/
if(strlen($user) <6)
{
$msg=$msg."(Please enter username that is more then 6 characters in
length)<br/>";
$flag="NOTOK";
}

if(strlen($pass_a) < 6)
{
$msg=$msg."(Please enter password that is more then 6 characters in
length)<br/>";
$flag="NOTOK";
}

if($pass_a != $pass_b)
{
$msg=$msg."(Your passwords don't line up)<br/>";
$flag="NOTOK";
}

/*********check for username********/

$file_a = fopen("user.txt", "r");

$i = 0;
while(!feof($file_a))
{
$userA[$i] = fgets($file_a);
$i++;
}

for($n=0; $n<$i; $n++)
{
$num = $num + substr_count($userA[$n], $user);
}
fclose($file_a);

if($num >= 1)
{
$flag = "NOTOK";
$msg=$msg."(Your username has already been taken)<br/>";
}


/*************************^^^^^^^^^^^*************************/


if($flag != "OK")
{
echo "<center>$msg <br> <input type='button' value='Retry'
onClick='history.go(-1)'></center>";
}

else
{
$file_a = fopen("user.txt", "a");
$file_b = fopen("pass.txt", "a");

fwrite($file_a, "\n,\"$user\"");
fwrite($file_b, "\n,\"$pass_a\");
echo "congrates you have now signed into the secret page<br/>";
fclose($file_a);
fclose($file_b);
}

?>
/
**********************************************************************************************************/


/***************************User.txt************not
real***************************************************/
"blah"
"blank"
"blog"
"bloogg"
/
***********************************************************************************************************/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация