Tātad es izdomāju uzšiverēt savu pirmo reģistrācijas sistēmu, bet man nez kapēc metās ārā errors, piemēram es ievadu

username - Juris

password - qwerty

confirm password - qwerty

email - juris@hotmail.com

Man izmet erroru - "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''user_info' ('username', 'password', 'email') VALUES (Juris, qwerty, Juris@hotma' at line 1"

btw, mans 1. darbs @ php.

 

Tātad - register.php

<html>
<form action="register.php" method="POST">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
Confirm password: <input type="password" name="conf_pass"><br>
Email: <input type="text" name="email"><br>
<input type="submit" value="Register!"><br>
</form>
</html>


<?php
$min_lenght = "4";
$max_lenght = "32";
$username = $_POST['username'];
$password = $_POST['password'];
$conf_pass = $_POST['conf_pass'];
$email = $_POST['email'];
require('mySQLcon.inc.php');


if(strlen($username)>$max_lenght || strlen($username) < $min_lenght || empty($username)){
die("You either left the username field blank or it's longer than 32 characters or less than 4 characters.");
}
if(strlen($password)>$max_lenght || strlen($password) < $min_lenght || empty($password)){
die("You either left the password field blank or it's longer than 32 characters or less than 4 characters.");
}
if($conf_pass!==$password){
die("The entered passwords dont match.");
}
if (strlen($email)>$max_lenght || strlen($email) < $min_lenght ||empty($email)) {
die("You either left the email field blank or it is longer than 32 characters or less than 4 characters.");
}
$username_check = mysql_query("SELECT username FROM user_info WHERE username='$username'");
$do_username_check = mysql_num_rows($username_check);

$email_check = mysql_query("SELECT email FROM user_info WHERE email='$email'");
$do_email_check = mysql_num_rows($email_check);

if ($do_username_check>0) {
    die('That username already exists.');
}
if ($do_email_check>0) {
    die('That email already exists.');
}
$insert_info = mysql_query("INSERT INTO 'user_info' ('username', 'password', 'email') VALUES ($username, $password, $email)");
if (!$insert_info) {
    die("There's a problem ". mysql_error());
}

?>

mySQLcon.inc.php

<?php
$mysql_host = 'hosts';
$mysql_name = 'lietotājs';
$mysql_pass = 'parole';
$mysql_db = 'db';

if(@mysql_connect($mysql_host, $mysql_name, $mysql_pass)){
    @mysql_select_db($mysql_db);
}else{
    die('');
}
?>

 

Datubazes pic, ja tas ko dod.

Laboja mad, labots 2x