0

So,I have recently started my development for my website,and I want to create a login system for questions,comments etc.When I work on my "signup.inc.php" file, I get this error:"syntax error,unexpected '}' in (file location) on line 12".The problem is that,there's no '}' on line 12.

Here's the code:

if (isset($_POST['signup-submit'])) { 

   require 'dbh.inc.php';

   $username = $_POST['uid'];
   $email = $_POST['mail'];
   $password = $_POST['pwd'];
   $passwordRepeat = $_POST['pwd-repeat'];

   if (empty($username) || empty($username) || empty($username) || empty($username)) {
     header("Location: ../signup.php?error=emptyfields&uid=".$username."&mail=".$email);
   }

}

If you have any questions,or want me to provide more info, leave a comment and I will try to answer as soon as I can.

MKE
  • 1
  • Is your condition really checking if the same variable `$username` is empty *four times*? – El_Vanja Apr 05 '20 at 00:36
  • And your logic is broken; if username or email are empty, you're still including them in the header url. What's that supposed to achieve? – El_Vanja Apr 05 '20 at 00:39
  • Well my code is not yet completed,plus this is my first time coding in php,and my first time coding in general,so I do have a lot of mistakes which I'm trying to repair as the time passes. – MKE Apr 05 '20 at 15:42
  • And it was checking for $username four times because I copy-pasted the code,and wanted to see if it works as planned,which doesn't. – MKE Apr 05 '20 at 15:44

1 Answers1

-1

I belive you need to close your header link.

Change:

"&mail=".$email); 

Into:

"&mail=".$email."");

I it is suppose to be:

header("link");

your code is currently producing

header("link); 

and goes beyond this point until end of script.

ikiK
  • 6,060
  • 3
  • 14
  • 37
  • This is incorrect. There is no need to add an empty string after a variable concatenation at the end of a string. – El_Vanja Apr 05 '20 at 00:35
  • @El_Vanja Seamed a bit too obvious so I used "I believe". A shot and a miss. Thank you. – ikiK Apr 05 '20 at 00:51
  • Such syntax errors are easily testable using an online parser and it doesn't take [more than a minute](https://3v4l.org/emkdt). Testing your assumptions before posting an answer is a good practice. These errors are even testable visually in cases like these where the string is not complicated - if the number of open and closed quotes matches, everything is fine. – El_Vanja Apr 05 '20 at 00:58
  • @El_Vanja You wouldn't believe, but today is first time I sow here on SO PHP parser, and it is in my bookmarks and I DID do as you suggested before posting answer here but peace of code I entered didn't produce any result. I will definitely use and learn that more. Just month ago I learned SQL fiddle. Very useful tools. – ikiK Apr 05 '20 at 01:05