FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


my sql create user problem





whitehole
I keep getting the error message:

Query failed: Access denied; you need the CREATE USER privilege for this operation

when trying to create users with a php script I am using:

Here is my code, i took out the username and password but everything else is what i am using now;

the html
Code:
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Title here!</title>
</head>
<body>

<form action="createlogin.php" method="POST">
Username:<input type="text" name="account"><br>
Password:<input type="password" name="password"><br>
email:<input type="email" name="email"><br>
<input type="submit" value="CREATE NEW ACCOUNT">



</form>



</body>
</html>


and the php

Code:


<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Title here!</title>
</head>
<body>

<?php

$dbh = mysql_connect('localhost', '', '') or die ('Could not connect: '.mysql_error());
mysql_select_db('whitehol_feedbackbuddy') or die ('Could not connect: '.mysql_error());



$account=$_POST['account'];
$password=$_POST['password'];
$email=$_POST['email'];

if (!isset($account) || !isset($password) || !isset($email)){

echo "Please go back and enter an account name and password with your email address.";
exit;
}

$query="create user ".$account." identified by '".$password."'";
$result = mysql_query($query) or die('Query failed: '.mysql_error());
//$privelages = mysql_query("grant select, insert on whitehol_feedbackbuddy.* to ".$account." identified by ".$password."");


echo "Account name: ".$account." was created sucessfully.<br>";
echo "Thank you for registering with White Hole Inc.";


?>


</body>
</html>
dayveday
I don't think that CREATE USER is actually what you want to do. Creating a user, as far as I understand, will create an account to have access to the SQL database. This isn't quite what you generally want from a website/server. Rather you have only one account which can access the database - this is the account used by your scripts to perform operations on the database/tables.

Rather, what you need to do is create a table of users and have your script make sure that a user has been successfully logged into the website before it will allow that user to make requests which will edit the database. Does that make sense?
whitehole
Yeah, I think that would work.

So i make a table with 3 fields, username, password, and email, and maybe a numeric field for a primary key with autoincrement.

then i let people add name/pass to that field with some kind of input.

Then, i do a query and if user and password match then i let them go onto the site??

I think that's what you're getting at?
Related topics
I have a problem....Mozilla Firefox
Wow.
Strange "mysql_num_rows()" error (Solved)
SQL and PHP
password protecting a directory
What do I do, I messed up !! I really LOVE HER!!
Installing WinXP Pro On WinME (Help Much Appreciated!)
mySQL create table problem (parse error)..
could not connect to the database
memberlist SQL
Oops my php files are not opening in IE?!
Could someone create a really simple login system???
mysql adding new user with shell
restart related problem
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.