Log in

View Full Version : having a hell of a time today..



Colin-Roberts
03-02-2008, 06:56 PM
Unexpected T_string


$query = “select * from users where username=’$username’ and password=’$password’”;

Invent
03-02-2008, 06:58 PM
$query = "SELECT * FROM `users` WHERE `username` = '".$username."' AND `password`= '".$password."'";

Colin-Roberts
03-02-2008, 07:02 PM
unexpected t-string again

$error = “Bad Login”;I fail to see the issue?

the line before the error:

if (mysql_num_rows($result) != 1) {
$error = “Bad Login”;

Blob
03-02-2008, 07:05 PM
Use " not “

Invent
03-02-2008, 07:05 PM
You're using the wrong symbol...

You're using “ when it's ".

Colin-Roberts
03-02-2008, 07:06 PM
;p thanks guys.

Colin-Roberts
03-02-2008, 07:10 PM
Is it possible using ajax or w.e to submit the form and if successfull show the members navi if not show the login again?

MrCraig
03-02-2008, 07:19 PM
yeah..

You can use scriptaculous ajax.updater and QueryString method.

Colin-Roberts
03-02-2008, 07:30 PM
grr what's wrong with this?

<?
if ($_SESSION['username'] = '".$username."'); {
echo("member stuff.");
}
include("login.html");
?>

How do i make it so it doesn't show the login after member stuff if there logged in?

Invent
03-02-2008, 07:41 PM
<?php
session_start(); // If this is the full document you require session_start

if ($_SESSION['username'] == $username)
{

echo("member stuff.");

}

include("login.html");

?>
You really don't get PHP, lol.

Assassinator
03-02-2008, 07:41 PM
<?
if ($_SESSION['username'] = '".$username."'); {
echo("member stuff.");
}
include_once "login.html";
?>

Invent
03-02-2008, 07:42 PM
<?
if ($_SESSION['username'] = '".$username."'); {
echo("member stuff.");
}
include_once "login.html";
?>

How's that going to work Assasinator...?

Colin-Roberts
03-02-2008, 07:43 PM
invent your code = http://zetolic.com/ still shows login.

MrCraig
03-02-2008, 07:44 PM
remove the include("login.html"); bit then..

EDIT:



<?php
session_start(); // If this is the full document you require session_start

if ($_SESSION['username'] == $username)
{

echo("member stuff.");

}
else
include("login.html");

?>

Should work.

Invent
03-02-2008, 07:46 PM
<?php
session_start(); // If this is the full document you require session_start

if ( isset( $_SESSION["username"] ) && $_SESSION['username'] == $username && !empty( $_SESSION["username"] ) )
{

echo("member stuff.");

}
else
{

include("login.html");

}

?>
Simple...

Colin-Roberts
03-02-2008, 07:46 PM
still shows login.html below it :(
I'm confused.

MrCraig
03-02-2008, 07:47 PM
Simon,
Surely you dont need the isset bit, If it contains the username then of course its going to be set?

Invent
03-02-2008, 07:47 PM
<?php
session_start(); // If this is the full document you require session_start

if ( isset( $_SESSION["username"] ) && $_SESSION['username'] == $username && !empty( $_SESSION["username"] ) )
{

echo("member stuff.");

}
else
{

include("login.html");

}

?>
That'll DEFINATELY work...


Surely you dont need the isset bit, If it contains the username then of course its going to be set?Actually, you probably do need it...

If the session ISN'T set then the value will be blank/null. If the $username variable isn't set (logged out) then it'll be blank/null. Using isset will stop it showing the members stuff if the session doesn't exists.

Colin-Roberts
03-02-2008, 07:50 PM
now even if i'm logged in it doesn't show the members links :( oh well.

Want to hide these adverts? Register an account for free!