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

Displaying Column Names
I have a question regarding the ability to show the column names from my table/query.
What I'm lo

Menu restriction
How can I restrict the individual menu that would appear when a user logs in so that all users are c

On page view, minus credit
Hello all, please, I need a little help with this script. I am charging one credit (credits can be p

Strange HTML Tag?
I recently noticed some odd HTML appear in some of the websites I host. Not all of them are run on a

php title problem
Hi,

I am having a problem managing my page title with PHP.

Currently I have my <

IIS & NW MII on the same server
Hi,

We're weighing the possibility to run both IIS and MII (NetWeaver) on the same server

Inserting 100x and 100y coordinates in mysql table - easy
Is there a way to insert this data into a mysql table named 'map' with the fields: 'x int 3' , 'y in

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

php mysql query from input textbox
Hi,

I have a text box, in that i have given the mysql query. I can able to get the query in v

How to show the difference between two data field in a database with php.
Hello php gurus,

how r u all... i'm not so well facing a typical problem please help me...<

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