-2

syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\latihan\Prosesdaftar.php on line 34

<?php
require_once("koneksi.php");

$username = $_POST['username'];
$pass = $_POST['password'];

$cekuser = mysql_query("SELECT * FROM user WHERE username = '$username'");

if(mysql_num_rows($cekuser) > 0) {
   echo "Username Sudah Terdaftar!";
   echo "Masih ada data yang kosong!";
   echo '<a href="daftar.php">Back</a>';
} else {
 if(!$username || !$pass) {

   $simpan = mysql_query("INSERT INTO user(username, password) VALUES('$username','$pass')");

   echo '<a href="daftar.php">Back</a>';
 } else {
   if($simpan) {

 }
     echo 'Pendaftaran Sukses, Silahkan <a href="login.php">Login</a>';
   } else {
     echo "Proses Gagal!";
   }
}
?>
   echo 'Pendaftaran Sukses, Silahkan <a href="login.php">Login</a>';
} else {

the problem is in the "else" what should i do?

Qirel
  • 25,449
  • 7
  • 45
  • 62
Diinsa
  • 1
  • 1
  • 2
    Some sensible formatting of your code will help you spot errors like these. Intent the code per control structure, and it becomes apparent what's wrong. – Qirel Jul 01 '18 at 14:39
  • 1
    **Don't store your passwords in plain-text!** This is not secure *at all!* PHP has built-in functions which you should use to handle storing of passwords, see the [`password_hash()`](http://php.net/manual/en/function.password-hash.php) function which is a lot more secure! – Qirel Jul 01 '18 at 14:40
  • 1
    [**Do not use `mysql_*` functions in new code**](http://stackoverflow.com/q/12859942). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [**red box**](http://php.net/mysql-connect)? Learn about [*prepared statements*](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://php.net/manual/en/mysqlinfo.api.choosing.php) can help you decide which. – Qirel Jul 01 '18 at 14:40
  • 1
    I honestly cannot believe someone would take the time to post a question as this when its basic programming logic. Sorry, but sometimes I just can't pat someone on the head and tell them they are a winner. – IncredibleHat Jul 01 '18 at 14:41
  • **Your code is wide open for SQL Injection Attacks** Look into using prepared statements when dealing with variable data added to sql queries. – IncredibleHat Jul 01 '18 at 14:43

1 Answers1

-1

There cannot be an else{} without an if{} before, so else {echo "Proses"; } alone is not correct