Jump to content

MYSQL problems (registration script)


mattd8752

Recommended Posts

I get the following feedback:
thisisatestusernamethisisatestregistrationkeythisisatestpassword540ee6cb238b047b425a326bf5cfdcc3thisisatestemailUsername is available...
Unknown column 'thisisatestusername' in 'field list'Your account should be registered. Try logging in! Login Page

From my registration script:
[code]
<?php
include "dbconnect.php";
if(!isset($_POST['register']) || !isset($_POST['regkey']) || !isset($_POST['username']) || !isset($_POST['password']) || !isset($_POST['email'])){
?>
<html>

<head>
<title>Registration Form</title>
</head>

<body>

<form method="POST" action="register.php">
Username:<input type="text" name="username" size="20"><br>
Password:<input type="password" name="password" size="20"><br>
Email:<input type="text" name="email" size="20"><br>
Registration Key:<input type="text" name="regkey" size="20"> (you need to get a registration key to sign up)<br>
<input type="submit" value="Submit" name="register">
</form>

</body>

</html>

<?php
}else{
//reg them
$username = $_POST['username'];
echo $username;
$key = $_POST['regkey'];
echo $key;
$pass = $_POST['password'];
echo $pass;
$pass = md5($pass);
echo $pass;
$email = $_POST['email'];
echo $email;
$found = mysql_result(mysql_query('SELECT count(0) FROM `users` WHERE `username` = "'.$username.'" LIMIT 1'), 0, 0);
if ( $found > 0 ){
echo ("Sorry, that username is already taken.");
die;
}else{
echo "Username is available...<br>";
mysql_query("INSERT INTO users (username,password,regkey,email) VALUES(".$username.",".$pass.",".$key.",".$email.")");
echo mysql_error();
echo "Your account should be registered.  Try logging in!  <a href=\"login.php\">Login Page</a>";
}
}
?>
[/code]

It is not placing anything in the database and you can probably see the MYSQL error, that is with me writing thisisatest* for every field and submitting, all the data is taken but none is being put into my database.  My DB connect DOES WORK, I have a working login script with the same DBconnect page.
Link to comment
https://forums.phpfreaks.com/topic/35284-mysql-problems-registration-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.