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'])){
Did you know?Explore Trending and Topic pages for more stories like this.
$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

Basic Question about Threading and PHP...
I have a page that I am working on and it is taking several hours to process. The basics of what th

textfield unchanged
hi,
i want my form to know whether its textbox is unchange or not.

if($textbox == 'unchang

Sending CC Info by email
I am a little bit less knowledgable in the security area as most developers and I know I have a lot

Error In Syntax
I got this error:

Code: Parse error: syntax error, unexpected '>' in /home/bucket/publ

does anyone know a php script to send mail using gmails/googles free smtp server
cause i heard u can do that but i dont know how

PECL uploadprogress for php5.2
Hey, I just installed PHP5 via .htaccess on my 1and1 Shared Hosting Account.

How would I exac

Prevention Help
How can I use PHP or any other language (feel free to move this thread) to prevent users doing scree

Changing files over
Just thought I'd start with the new forums looking really nice .

Ok basically I've made this

turning an array into a string then poping it into a db
Hi im just wondering how you get a requested array into a single string then pop it into the db so f

Script not running properly
Hello Everyone
This is a basic script for posting to a database. I'm not sure why it doesn't work

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