Jump to content

Recommended Posts

Parse error: syntax error, unexpected '}' in /misc/39/000/171/334/2/user/web/test.eaglelegend.com/login.php on line 23

 

Sorry for the messy code, its just I am trying to change the site from cookies to sessions, so yeah, I kind of figured how to do that, only thing is, is errors do come with testing things >_<, thats why I set up the test site for temporary use.

 

here is the code:

<?php
include("header.php");

$username = $_POST['username'];
$password = md5($_POST['password']);

if($username && $password) {
$check = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`=\"$username\" AND `password`=\"$password\""));

if($check == 1) {
	        $_SESSION['ELv2'] = $username;
	        session_register('ELv2');
 	 	Header("Location: index.php");
 	}
 	else {
 	 	print "Cant set cookie";
 	}
}
else {
 	print "Sorry, username/password mismatch!";
}

}
else {
?>
<h2>Login</h2><p>
<form action="login.php" method="post">
Username<br>
<input type="text" name="username" class="text_box" size="20" value="Username" title="Please enter the Username you registered here with." alt="Please enter the Username you registered here with."><p>
Password<br>
<input type="password" name="password" class="text_box" size="20" value="password" title="Please enter the Password you registered here with." alt="Please enter the Password you registered here with."><p>
<input type="submit" class="text_box" value=" Login " title="Click here to log in." alt="Click here to log in."></form>
<? 
}

include("footer.php");
?>

 

incase you didnt notice, it is login code btw!

Link to comment
https://forums.phpfreaks.com/topic/105825-parse-error/
Share on other sites

session_register is depreciated. Do not use this function. Just use $_SESSION['your_var'] = 'somevalue' to set session variables.

 

Also I donot recommend the following:

$username = $_POST['username'];
$password = md5($_POST['password']);

if($username && $password) {

This is sloppy in my opinion.

I'd do:

if(isset($_POST['username']) && isset($_POST['password'])) {
    $username = $_POST['username'];
    $password = md5($_POST['password']);

Link to comment
https://forums.phpfreaks.com/topic/105825-parse-error/#findComment-542393
Share on other sites

as you guys know, I bought the code originally from a rubbish programmer, sorry if that programmer is reading but well, I am trying to make the code alot safer, coding anyway, so whatsthe differance between

if(isset($_POST['username']) && isset($_POST['password'])) {
    $username = $_POST['username'];
    $password = md5($_POST['password']);

and the original one? and ok, so yeah as I have and only just started using sessions so, could you explain more about this new one you want me to use instead of the session register?

 

EDIT: Also, how do I change youre "         if(session_register('ELv2')){" to the new one you mentioned that is better?

Link to comment
https://forums.phpfreaks.com/topic/105825-parse-error/#findComment-542420
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.