473,383 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Php signup problem

jon
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"
/
************************************************** ************************************************** *******/

Feb 2 '07 #1
0 1339

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Rudi Ahlers | last post by:
I tried the following: http://intranet/signup.php?Domain=newdomain.com, and it doesn't seem to return any values In my script I have the following: <? print $_POST; $DomainName = $_POST;...
3
by: David | last post by:
hi i have a basic signup POST form, with php on the same page. how do i return to this page with all the entries still present, yet with a message at the top, for when the user enters one...
3
by: Dustin | last post by:
I am developing a website where users can sign up for a service. They essentially can become a memeber. It will allow anyone to sign up, but I need to make it so only humans can sign up. I need...
2
by: .Net Sports | last post by:
I need to find a script that whereas a user signs up for your website and when he hits submit, an email goes to his email box with a confirmation link (generated by random number) for him to click...
6
by: atcohaz | last post by:
Hi everybody, I have a personal server (I learning) with Linux with using Cpanel I only need such script which enables me to create email accounts without logging into cPanel. And in which I...
1
by: siddu | last post by:
Hi .. I am having signup page that contains username,pwd,confpwd,Email,Address and one save button . when user enter his details and press save button it should save details in database. i have...
2
by: fredtbx | last post by:
Using ASP.NET 2.0 Login control and CreateUserWizard Hi, I can't figure out how, when I have the Login control up on Login.aspx and if the user doesn't have an account, to point to Signup.aspx...
1
by: kang jia | last post by:
hi when user entered particulars in signuppage and click" signup" button, i will direct them to do_signup.php. if say the NRIC is dupicate in datebase, i will redirect them back to signup page...
2
by: nazgul42 | last post by:
Ok... this is my third problem today, but here goes: On my signup page for my login system on my website, I have some code that is supposed to check if a username is already taken and give an error...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.