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

SAP BCS. BPS
Hi all,

I am seeking reading note on the following in BW

BCS, BPS
ADVANCE

Creating a custom API
I'm creating a site, and I need to create a basic API. Unfortunately I have no idea where to start.

Character Set Setup
Whats the best character set to use if you want every character to work, and also how do you make yo

Create a form of 2 numbers input and find the greatest.
Hi, everybody.

I have a homework in my training of php, which ask you to make a form that ask

Text to picture Generator
Hello, i have found this script and it works really good^^ But i have one problem, i would like to c

Applet JTextField Size Problem
Hello,

I recently started making an applet to calculate certain values for airplanes. However

Really need helps regarding Pagination with Sort
I need someone helps regarding pagination problem...i actually want to make my page limited to let s

Accessing element of object array
Hello

My object looks like this:


Array ( [0] => User Object ( [id] =>

Credit card verification
I have a client who wants to process credit card transactions from his web site rather than the goin

Gerenate tabel in Php
I whant to generate a tabel takeing data from database like this one so the results to be display on

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