|
-
Mar 21st, 2006, 11:47 AM
#1
Thread Starter
Addicted Member
Parse error :(
Hi,
I get a parse error at line 118:
PHP Code:
<?php
include('config.php');
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
if (isset($_COOKIE['BSComputersU']) && isset($_COOKIE['BSComputersP'])) {
header("Location: main.php");
}else{
if ($_POST['username']) {
//did they supply a password and username
$username=$_POST['username'];
$password=$_POST['password'];
if ($password==NULL) {
echo "<center>Du har ikke indtastet et kodeord!</center><br>
<center>
<h1>Login</h1>
<form action='check.php' method='POST'>
<table style='border:1px solid #000000;'>
<tr>
<td align='right'>
Brugernavn: <input type='text' size='15' maxlength='25' name='username'>
</td>
</tr>
<tr>
<td align='right'>
Kodeord: <input type='password' size='15' maxlength='25' name='password'>
</td>
</tr>
<tr>
<td align='center'>
<input type='submit' value='Login'>
</td>
</tr>
<tr>
<td align='center'>
<a href='register.php'>Opret bruger her</a>
</td>
</tr>
</table>
</form></center>
";
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != md5($password)) {
echo "<center>Du har indtastet forkert brugernavn eller kodeord! Prøv igen<br><center>
<h1>Login</h1>
<form action='check.php' method='POST'>
<table style='border:1px solid #000000;'>
<tr>
<td align='right'>
Brugernavn: <input type='text' size='15' maxlength='25' name='username'>
</td>
</tr>
<tr>
<td align='right'>
Kodeord: <input type='password' size='15' maxlength='25' name='password'>
</td>
</tr>
<tr>
<td align='center'>
<input type='submit' value='Login'>
</td>
</tr>
<tr>
<td align='center'>
<a href='register.php'>Opret bruger her</a>
</td>
</tr>
</table>
</form></center>
</center>";
}else{
if (isset($_POST['husklogin'])){
setcookie('BSComputersU', $username, time() + 3600 * 24 * 365);
setcookie('BSComputersP', $password, time() + 3600 * 24 * 365);
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
$_SESSION["s_username"] = $row['username'];
header("Location: index.php");
}
}
}
?>
<script language="javascript" type="text/javascript">
function createRequestObject()
{
var request_o; //declare the variable to hold the object.
var browser = navigator.appName; //find the browser name
if(browser == "Microsoft Internet Explorer"){
/* Create the object using MSIE's method */
request_o = new ActiveXObject("Microsoft.XMLHTTP");
}else{
/* Create the object using other browser's method */
request_o = new XMLHttpRequest();
}
return request_o; //return the object
}
var http = createRequestObject();
function destorySession()
{
try
{
http.open('get', 'destroy.php');
http.send(null);
}
catch(Exception)
{
http = createRequestObject();
destorySession();
}
}
window.onunload = destorySession();
</script>
But I can't see the prob
-
Mar 21st, 2006, 11:48 AM
#2
Thread Starter
Addicted Member
Re: Parse error :(
The husklogin is a checkbox
-
Mar 21st, 2006, 01:32 PM
#3
-
Mar 21st, 2006, 01:44 PM
#4
<?="Moderator"?>
Re: Parse error :(
Ack, don't print out large chunks of html from php just makes things messy. Instead just close the php tags and write the html normally.
eg
PHP Code:
<?
//loads of php
?>
<!-- loads of html -->
<?
//loads more php
?>
This means you won't get parse errors from where you have not escaped a string correctly.
-
Mar 21st, 2006, 05:05 PM
#5
Thread Starter
Addicted Member
Re: Parse error :(
I know, but it's something I've copy-pasted 
The line 118 is where the javascript ends
-
Mar 21st, 2006, 05:15 PM
#6
Re: Parse error :(
 Originally Posted by sveegaard
I know, but it's something I've copy-pasted
The line 118 is where the javascript ends
I cannot speak for anyone else here. But I am not even going to look at that code until it is properly indented.
-
Mar 22nd, 2006, 02:11 AM
#7
Conquistador
Re: Parse error :(
You're missing some brackets.
PHP Code:
<?php
include('config.php');
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
if ( isset( $_COOKIE['BSComputersU'] ) && isset( $_COOKIE['BSComputersP'] ) )
{
header( "Location: main.php" );
}
else
{
if ($_POST['username'])
{
//did they supply a password and username
$username=$_POST['username'];
$password=$_POST['password'];
if ($password==NULL) {
// some html
}
else
{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != md5($password))
{
// some more html
}
else
{
if (isset($_POST['husklogin']))
{
setcookie('BSComputersU', $username, time() + 3600 * 24 * 365);
setcookie('BSComputersP', $password, time() + 3600 * 24 * 365);
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
$_SESSION["s_username"] = $row['username'];
header("Location: index.php");
}
}
}
} // $_POST['username']
}
?>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|