Создаю спокойно регистрацию на сайте, и тут хобана, и всё!
PHP:
<?php
$mysqli = new mysqli("localhost", "rootuser", "password", 'basename')
or die("Error " . mysqli_error($mysqli));
$data = $_POST;
if(isset($data['do_signup'])) {
$errors = array();
$result = $mysqli->query("SELECT id FROM users WHERE username = '{$data['username']}'");
$row = $mysqli_result::fetch_array($result, MYSQLI_NUM);
$data['username'] = stripslashes($data['username']);
$data['username'] = htmlspecialchars($data['username']);
$data['password'] = stripslashes($data['password']);
$data['password'] = htmlspecialchars($data['password']);
if (!empty($row['id'])) {
$errors[] = 'Sorry, this username is already registered.';
}
if(trim($data['username']) == '') {
$errors[] = 'Enter the username.';
}
if(strlen($data['username']) < 3) {
$errors[] = 'Your username cannot be shorter than three characters.';
}
if(strlen($data['username']) > 33) {
$errors[] = 'Your username cannot be longer than three characters.';
}
if(strlen($data['password']) < 8) {
$errors[] = 'Your password cannot be shorter than eight characters.';
}
if(strlen($data['password']) > 100) {
$errors[] = 'Your password cannot be longer than one hundred characters.';
}
if(empty($errors)) {
$result2 = mysqli("INSERT INTO users (username,password) VALUES('{$data['username']}','{$data['password']}')");
if($result2 == 'TRUE') {
echo "You are was registred!";
} else {
echo '<div style="color: red;">.array_shift($errors)</div><hr>';
}
} else {
echo '<div style="color: red;">.array_shift($errors)</div><hr>';
}
}
?>
HTML FORM:
<div id="auth">
<form name="sign-up" method="POST" action="signup.php">
<label for="username"></label><input type="text" id="username" placeholder="Username"
name="username", value="<?php echo @$data['username']; ?>" required>
<br>
<label for="password"></label><input type="password" id="password" placeholder="Password"
name="password", value="<?php echo @$data['password']; ?>" required>
<br>
<br>
<input type="Submit" id="submit" value="Sign up" name="do_signup">
</form>
</div>
Error:
Fatal error: Class name must be a valid object or a string in D:\home\domen123.org\www\signup.php on line 10
Версия php 5.3.13, версия mysql 5.5, локальный сервер Denwer