Buggy registration system


Posted on 16th Feb 2014 07:03 pm by admin

Hey, I just started scripting in PHP, and I ran into a few problems.
Code: <?php
include('config.php');
if (isset($_POST['set'])){
$user=mysql_real_escape_string($_POST['user']);
$pass=mysql_real_escape_string(md5($_POST['pass']));
if ($user="" or $pass=""){
echo 'Invalid Username/Password';
}
else{
mysql_select_db("db_mycountdown",$db_connect);
$sql=mysql_query("SELECT * FROM users WHERE username='$user'",$db_connect);
$fetch = mysql_num_rows($sql);
if ($fetch>0){
unset($user);
echo 'Error: This user already exists!
';
}
else{
mysql_select_db("db_mycountdown",$db_connect);
$sql = mysql_query("INSERT INTO users (username, password)
VALUES ('$user','$pass')",$db_connect);
echo 'Account Successfully Created!';
}
}
}

echo '<a href="Index.php">Already have an account? Log in!</a>
<form action="" method="post">
Username:<br/>
<input type="text" name="user"/><br />
Password:<br/>
<input type="password" name="pass"/><br />
Confirm Password:<br/>
<input type="password" name="passconfirm"/><br /><br />

<input type="submit" name="set" value="Register" /> <br />
</form>';
?>
my php code here seems really buggy. Can anyone point out any errors? Thanks

No comments posted yet

Your Answer:

Login to answer
232 Like 10 Dislike
Previous forums Next forums
Other forums

Load Animated Image while cache is serve
I have a page that loads up using cache and took about 1 to 2 minutes before it loads to the page. <

How would I do "Users not logged in since *** delete them"
I know how I would set this up, and delete the user roughly.
I'll create a table called "Use

division gives infinity anser
int main()
{
int z=0;
int i=1/z;
cout<
}

It doesn't throw a

Custom CMS
This is a big custom CMS script I'd like to develop and would like some help atleast figuring out wh

regex for quoted text within a string
I am still getting the hang of regex expressions, but I cant seem to figure out how I would escape q

Request-URI Too Large
I have created a simple submit form for a mysql database that puts a piece of code into database.<

Database/Table Collation
What is the Database, and table collations used for? i don't understand what there used for since co

Warning message
I've put a website that I was doing live and I'm getting this warning message when I try to add a ne

Kill a process
I have a question - how can I kill a process from a command line or by using Oracle SQL Developer? I

PHP friend keyword equivalent
is there a PHP equivalent for the C++ friend keyword?

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash