Jump to content

[SOLVED] unexpected T_ELSE


S A N T A

Recommended Posts

Ok so for a blog I'm making I'm working on a login so i tried to get it to say "Incorrect login blah,blah,blah" but i get the error:

 

 

Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\login.php on line 28

 

from this code:

 

<?php

require("config.php");
session_start();

$db = mysql_connect($dbhost, $dbuser);
mysql_select_db($dbdatabase, $db);

if($_POST['submit']) {
$sql = "SELECT * FROM logins WHERE username = '" . $_POST['username'] . "' AND password = '" . $_POST['password'] . "';";

$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
}
if($numrows == 1) {
$row = mysql_fetch_assoc($result);
session_register("USERNAME");
session_register("USERID");

$_SESSION['USERNAME'] = $row['username'];
$_SESSION['USERID'] = $row['id'];

header("Location: " . $config_basedir);
}
else {
header("Location: " . $config_basedir . "/login.php?error=1");
}
[b]else {[/b]

	require("header.php");

	if($_GET['error']) {
	echo "Incorrect login, please try again!";
	}
?>


<form action="<?php echo $SCRIPT_NAME ?>" method="post">

<table>
<tr>
<td>Username</td>
<td><input type="text" name="username"</td>
</td>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Login!"></td>
</tr>
</tr>
</table>
</form>
}
<?php
require("footer.php");
?>

 

The letters in bold is line 28

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/103222-solved-unexpected-t_else/
Share on other sites


it must be like this......

check it out....


if($_POST['submit']) {
$sql = "SELECT * FROM logins WHERE username = '" . $_POST['username'] . "' AND password = '" . $_POST['password'] . "';";

$result = mysql_query($sql);
$numrows = mysql_num_rows($result);

if($numrows == 1) {
$row = mysql_fetch_assoc($result);
session_register("USERNAME");
session_register("USERID");

$_SESSION['USERNAME'] = $row['username'];
$_SESSION['USERID'] = $row['id'];

header("Location: " . $config_basedir);
}

else {
header("Location: " . $config_basedir . "/gane/error.php?error=1");
}
}
else {

	//require("header.php");

	if($_GET['error']) {
	echo "Incorrect login, please try again!";
	}

?>


<form action="<?php echo $SCRIPT_NAME ?>" method="post">

<table>
<tr>
<td>Username</td>
<td><input type="text" name="username"</td>
</td>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Login!"></td>
</tr>
</tr>
</table>
</form>
<?
}

?>
<?php
require("footer.php");
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.