422,363 Members | 2,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,363 IT Pros & Developers. It's quick & easy.

Parse error: syntax error, unexpected '$true' (T_VARIABLE) in C:\xampp\htdocs\downloa

P: 2
Parse error: syntax error, unexpected '$true' (T_VARIABLE) in C:\xampp\htdocs\download\register.php on line 19
1 Week Ago #1
Share this Question
Share on Google+
1 Reply


P: 2
<?php
$db = new mysqli('localhost','root','','felhasznalok');
if (isset($_POST['submit'])) {
$errors = array();
$true = true;
if (empty($_POST['username'])) {
$true = false;
array_push($errors, "A felhasználónév üres!");
}
if (empty($_POST['password'])) {
$true = false;
array_push($errors, "A jelszó üres!");
}
if (empty($_POST['password_2'])) {
$true = false;
array_push($errors, "A jelszó megerősítés üres!");
}
if (!($_POST['password']==$_POST['password_2'])
$true = false;
array_push($errors, "A jelszavak nem egyeznek!");
}
if ($true) {
$username = mysqli_real_escape_string($db, $_POST['username']);
$password = mysqli_real_escape_string($db, $_POST['password']);
$password = md5($password);

$sql = "INSERT INTO users(username, password, Date) VALUES('$
username', '$password' ,NOW())";
$db->query($sql);
session_start();
$_SESSION['username'] = $username;
header('location: home.php');

}
}
$db->close();
?>
<html>
<head>

</head>
<body>
<form action="register.php" method="POST"/>
username<input type="text" name="username"/>
password<input type="password" name="password"/>
re_password<input type="password" name="password_2"/>
<input value="Regisztráció" type="submit" name="submit"/>
</form>
<?php
if (!empty($errors)) {
foreach ($errors as $key) {
echo $key. "<br/>";
}


}

?>
</body>
</html>
1 Week Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.