Problema con la creacion usuarios y login

Buenos dias.

Estoy tratando de hacer una web con un minijuego de trivial para jugar con mis amigos , tengo conocimientos basicos y he estado navegando e informandome por distintos foros y ejemplos, para tratar de realizarlo y avanzar.

Estoy teniendo unos problemas con el registro de usuario y reconocimiento dentro de la web.

Llevo peleandome con esto, dias y no consigo avanzar.

Si alguien mas experto puede ayudarme, me seria de mucha utilidad.
La web es http://thetruth.hol.es/
Servidor Hostinger y base de datos PHPMYADMIN

Disculpen las molestias, si alguien quiere que le pase parte del codigo o algo del codigo indicarmelo.

www.forosdelweb.com/f18/proyecto-web-trivial-1090473/
Hola!

Primero que nada, sería MUY útil que nos dijeras que problema tienes :P.

Segundo, aunque no muy importante, utilizas como gestor de base de datos MySQL, pues PhpMyAdmin es solo una interfaz gráfica (sin desmerecer el producto, que es increíblemente bueno) para administrar las bases de datos.

Saludos!
No consigo que me registre en la base de datos los nuevos usuarios para poder trabajar por usuarios y loguearlos despues.

No me da error el codigo pero no me los registra aun asi.
require_once "config.php";

if (strlen(trim($strSessionPath)) > 0)
    session_save_path($strSessionPath);

session_start();

$boolError = false;
$strAction = "";
$strMessage = "";
$strName = "";
$strPassword1 = "";
$strPassword2 = "";
$strTempDBInfo = "";

// Critical Error checking
if (empty($_SESSION)) {
    $_SESSION['name'] = "";
    $_SESSION['message'] = "You must log in to proceed.";
    header("Location: index.php");
    exit;
}
else {
    $strAction = $_SESSION['action'];
}

// User Error checking
if (!empty($HTTP_POST_VARS['name'])) {
    $strName = $HTTP_POST_VARS['name'];
}
elseif ($strAction == "Create New User") {
    $strMessage = "User was NOT created! You must specify a user. ";
    $boolError = true;
}

// boolError checks are in there own clause instead of merging them with the nested if statement.
// Otherwise, the error message of the real error will be overwritten by the last message in the
// last error check.
if (!$boolError) {
    if (!empty($HTTP_POST_VARS['password1'])) {
        $strPassword1 = $HTTP_POST_VARS['password1'];
    }
    else {
        $strMessage = "You must specify a password.";
        $boolError = true;
    }
}

if (!$boolError) {
    if (!empty($HTTP_POST_VARS['password2'])) {
        $strPassword2 = $HTTP_POST_VARS['password2'];
    }
    else {
        $strMessage = "You must validate your password by typing it twice.";
        $boolError = true;
    }
}

// $boolError can be merged with if statements if there is no 'else' clause
if (!$boolError && ((strlen($strPassword1) < 4) || (strlen($strPassword1) > 32))) {
    $strMessage = "Change was NOT successful! Password must be no shorter than 4 characters and no longer than 32 characters.";
    $boolError = true;
}

if (!$boolError && ($strPassword1 != $strPassword2)) {
    $strMessage = "Change was NOT successful! New password was not the same as the retyped password.";
    $boolError = true;
}

if (!$boolError) {
    $strTempDBInfo = DBTYPE . "_pconnect";
    $conn = $strTempDBInfo($DB_HOST, $DB_USER, $DB_PASS);

    if (!$conn) {
        $strTempDBInfo = DBTYPE . "_error";
        $strMessage = "Unable to connect to DB server: " . $strTempDBInfo($conn);
        $boolError = true;
    }
    else {
        $strTempDBInfo = DBTYPE . "_select_db";
    }
}

if (!$boolError && (!$strTempDBInfo($DB_NAME))) {
    $strTempDBInfo = DBTYPE . "_error";
    $strMessage = "Unable to select DB name: " . $strTempDBInfo($conn);
    $strTempDBInfo = DBTYPE . "_close";
    $strTempDBInfo($conn);
    $boolError = true;
}

if (!$boolError) {
    if ($strAction == "Create New User") {
        $sql = "SELECT UserName FROM login WHERE UserName = '" . $strName . "'";
        $strTempDBInfo = DBTYPE . "_query";
        $result = $strTempDBInfo($sql);

        if (!$result) {
            $strTempDBInfo = DBTYPE . "_error";
            $strMessage = "Could not successfully run query ($sql) from DB: " . $strTempDBInfo($conn);
            $boolError = true;
        }
        else {
            $strTempDBInfo = DBTYPE . "_num_rows";

            if ($strTempDBInfo($result) != 0) {
                $strMessage = "This user already exists.";
                $boolError = true;
            }
        }
    }
}

if (!$boolError) {
    if ($strAction == "Change Password") {
        $sql = "UPDATE login SET UserPassword = '$strPassword1' " .
            "WHERE UserName = '$strName'";
    }

    if ($strAction == "Create New User") {
        $strUserLastIP = $_SERVER['REMOTE_ADDR'];
        $sql = "INSERT INTO login ( UserName, UserPassword, UserLastIP ) " .
            "VALUES ('$strName', '$strPassword1', '$strUserLastIP')";
    }

    $strTempDBInfo = DBTYPE . "_query";
    $result = $strTempDBInfo($sql);

    if (!$result) {
        $strTempDBInfo = DBTYPE . "_error";
        $strMessage = "Could not successfully run query ($sql) from DB: " . $strTempDBInfo($conn);
        $boolError = true;
    }
    else {
// If $strMessage is not empty and $boolError is false then it's just a Message.
// Otherwise, it's an Error Message.
        if ($strAction == "Change Password") {
            $strMessage = "Password successfully changed.";
        }

        if ($strAction == "Create New User") {
            $strMessage = "User successfully added.";
        }

        $boolError = false;
    }

    $strTempDBInfo = DBTYPE . "_close";
    $strTempDBInfo($conn);
}

$_SESSION['message'] = $strMessage;
header("Location: options.php"); 
require_once "config.php";

if (strlen(trim($strSessionPath)) > 0)
session_save_path($strSessionPath);

session_start();

$strName = "";
$strMessage = "";
$strAction = "";

if (empty($_SESSION))
{
$_SESSION['action'] = $strAction = "Crear nuevo Usuario";
}
else
{
if (strlen(trim($_SESSION['name'])) > 0)
{
$strName = $_SESSION['name'];
$_SESSION['action'] = $strAction = "Cambiar Contraseña";
}
else
{
$strName = "";
$_SESSION['action'] = $strAction = "Crear nuevo Usuario";
}

if (!empty($_SESSION['message']))
{
$strMessage = trim($_SESSION['message']);
}
}
?>

<html>
<head>
<title>Registro</title>
<meta charset="UTF-8">
</head>
<body>
<?php
if (strlen(trim($strMessage)) > 0)
{
echo $strMessage;
$_SESSION['message'] = "";
}
?>

<table width='800'>
<tr>
<td width='160'><table></table></td>
<td width='640' align='center' style="font-weight: bold; font-size:25px;">
<table><?php echo $strAction ?></table>
</td>
</tr>
</table>

<hr>
<form name='options' action='user.php' method='POST'>
<table width='800'>
<tr>
<td width='160' valign='center' align='center' STYLE='background-image:url(images/count.png); background-repeat: no-repeat; background-position:center center;''>
<table>
<tr>
<td STYLE='color: #000000; font-size: 20px;'>
<?php
if ($strAction == "Cambiar Contraseña")
{
echo "<a href='main.php' accesskey='b'>[<span STYLE='color: red'>B</span>ack]</a>";

}

if ($strAction == "Crear nuevo Usuario")
{
echo "<a href='logout.php' accesskey='l' >[<span STYLE='color: red'>L</span>oguearse]</a>";
}
?>
</td>
</tr>
</table>
</td>
<td width='640' align='center'>
<table>
<tr><td><u>U</u>suario:</td></tr>
<tr>
<td>
<?php
if ($strAction == "Cambiar Contraseña")
{
echo "<input type='text area' name='name' accesskey='u' size='10' readonly value='$strName'>";
}

if ($strAction == "Crear nuevo Usuario")
{
echo "<input type='text area' name='name' accesskey='u' size='10'>";
}
?>
</td>
</tr>
<tr><td>Nueva <u>C</u>ontraseña:</td></tr>
<tr><td><input type='password' name='password1' accesskey='p' size='10'></td></tr>
<tr><td><u>R</u>epetir:</td></tr>
<tr><td><input type='password' name='password2' accesskey='r' size='10'></td></tr>
<tr><td><input type='submit' name='submit' value='Guardar' class='button'></td></tr>
</table>
</td>
</tr>
</table>
</form>

<?php require_once "footer.php"; ?>
</body>
</html>

<script type="text/javascript">
<!--
if (document.options.name.value.length == 0 )
{
document.options.name.focus();
}
else
{
document.options.password1.focus();
}

document.onkeypress=keyevent;

function keyevent(e)
{
var c;

c=String.fromCharCode(window.event.keyCode).toUppe rCase();
target=window.event.srcElement;

if (target.nodeName.toUpperCase() == 'INPUT')
{
if (target.type.toUpperCase() == 'SUBMIT')
{
if (document.options.name.value.length == 0 )
{
if (c == 'L') { window.location='logout.php';; return false; }
}
else
{
if (c == 'B') { window.location='main.php';; return false; }
}
}
}
else
{
if (document.options.name.value.length == 0 )
{
if (c == 'L') { window.location='logout.php';; return false; }
}
else
{
if (c == 'B') { window.location='main.php';; return false; }
}
}
}
//-->
</script>
require_once "config.php";

if (strlen(trim($strSessionPath)) > 0)
session_save_path($strSessionPath);

session_start();

$intUserNumber = 0;
$strName = "";
$strPassword = "";
$boolError = false;
$strTempDBInfo = "";

if (empty($HTTP_POST_VARS['name']))
{
$_SESSION['usernumber'] = 0;
$_SESSION['name'] = "";
$_SESSION['message'] = "Datos Incorrectos";
$boolError = true;
}
else
{
$strName = $HTTP_POST_VARS['name'];
$strPassword = $HTTP_POST_VARS['password'];
}

if (!$boolError)
{
$strTempDBInfo = DBTYPE."_pconnect";
$conn = $strTempDBInfo($DB_HOST,$DB_USER,$DB_PASS);
}

if (!$boolError && !$conn)
{
$_SESSION['usernumber'] = 0;
$_SESSION['name'] = "";
$strTempDBInfo = DBTYPE."_error";
$_SESSION['message'] = "Unable to connect to DB server: " . $strTempDBInfo($conn);
$boolError = true;
}

$strTempDBInfo = DBTYPE."_select_db";

if (!$boolError && (!$strTempDBInfo($DB_NAME)))
{
$_SESSION['usernumber'] = 0;
$_SESSION['name'] = "";
$strTempDBInfo = DBTYPE."_error";
$_SESSION['message'] = "Unable to select DB name: " . $strTempDBInfo($conn);
$boolError = true;
}

if (!$boolError)
{
$sql = "SELECT UserNumber, UserName FROM login " .
"WHERE UserName = '$strName' AND UserPassword = '$strPassword'";

$strTempDBInfo = DBTYPE."_query";
$result = $strTempDBInfo($sql);

if (!$result)
{
$_SESSION['usernumber'] = 0;
$_SESSION['name'] = "";
$strTempDBInfo = DBTYPE."_error";
$_SESSION['message'] = "Could not successfully run query ($sql) from DB: " . $strTempDBInfo($conn);
$boolError = true;
}
}

if (!$boolError)
{
$strTempDBInfo = DBTYPE."_num_rows";

if ($strTempDBInfo($result) == 0)
{
$_SESSION['usernumber'] = 0;
$_SESSION['name'] = "";
$_SESSION['message'] = "User not found.";
$boolError = true;
}
else
{
$strTempDBInfo = DBTYPE."_fetch_assoc";
$row = $strTempDBInfo($result);

$_SESSION['usernumber'] = $row['UserNumber'];
$_SESSION['name'] = $row['UserName'];

//Updte UserLastIP here
$strUserLastIP = $_SERVER['REMOTE_ADDR'];
$sql = "UPDATE login SET UserLastIP = '$strUserLastIP' " .
"WHERE UserName = '".$row['UserName']."'";

$strTempDBInfo = DBTYPE."_query";
$result = $strTempDBInfo($sql);

if (!$result)
{
$strTempDBInfo = DBTYPE."_error";
$strMessage = "Could not successfully run query ($sql) from DB: " . $strTempDBInfo($conn);
$boolError = true;
}
else
{
$_SESSION['message'] = "";
$boolError = false;
}
}
}

if ($boolError)
{
header("Location: index.php");
}
else
{
header("Location: main.php");
}
?>
require_once "config.php";

if (strlen(trim($strSessionPath)) > 0)
session_save_path($strSessionPath);

session_start();

$strMessage = "";

if (!empty($_SESSION['message'])) {
$strMessage = trim($_SESSION['message']);
}
?>

<html>
<head>
<title>Registro</title>
<meta charset="UTF-8">
</head>
<body>

<center><img src="images/yoshua.png" width="50%" height="40%"></center><br><hr>

<form name="login" action='login.php' method='POST'>
<table width='800'>
<tr>
<td width='160' valign='middle' align='center' STYLE='background-image:url(images/count.png); background-repeat: no-repeat; background-position:center center;'>
<table>
<tr><td STYLE='color: #000000;'>
<a href="options.php" accesskey='c'style=" font-size:20px;">
[<span STYLE="color: red">C</span>rear una cuenta]</a></td></tr>
</table>
</td>
<td width='640' align='center'>
<?php
if (strlen(trim($strMessage)) > 0) {
echo '<font size="5"><b>'.$strMessage.'</b></font>';
$_SESSION['message'] = "";
}
?>
<table>
<tr><td><u>N</u>ick:</td></tr>
<tr><td><input type='text area' name='name' accesskey='u' size='10'></td></tr>
<tr><td><u>C</u>ontraseña:</td></tr>
<tr><td><input type='password' name='password' accesskey='p' size='10'></td></tr>
<tr><td><input type='submit' name='submit' value='Logueate' class='button'></td></tr>
</table>
</td>
</tr>
</table>
</form>

<?php require_once "footer.php"; ?>
</body>
</html>

<script type="text/javascript">
<!--
document.login.name.focus();
document.onkeypress = keyevent;

function keyevent(e)
{
var c;

c = String.fromCharCode(window.event.keyCode).toUpperC ase();
target = window.event.srcElement;

if (target.nodeName.toUpperCase() == 'INPUT')
{
if (target.type.toUpperCase() == 'SUBMIT')
{
if (c == 'C') {
window.location = 'options.php';
;
return false;
}
}
}
else
{
if (c == 'C') {
window.location = 'options.php';
;
return false;
}
}
}
//-->
</script>
Os he puesto un poco el codigo que estoy usando y que he reutilizado, viendo videos y alguno ejemplos de internet.

Si necesitais algo mas o se me paso algo,indicarmelo.

Gracias por adelantado.
Hmmmm... comienza por hacer esto en todos los archivos donde se reciban datos POST o GET:

<?php

$HTTP_POST_VARS = &$_POST;
$HTTP_GET_VARS = &$_GET;

// El resto del código
?>

En las versiones superiores o iguales a PHP 4.3, $HTTP_[POST|GET]_VARS ya no existen.
Buenos dias.

Ya he ehcho los cambios de codigo que me habias dicho en todos los archivos php,

Si kieres te los reenvio modificados.

El error que me da ahora es el siguiente: Could not successfully run query () from DB: Query was empty

Sigo sin conseguir progresar en la creacion de usuarios y logueado.
¿Podrías poner el error completo? En qué línea ocurre el error, en que archivo, etc.
Como puedo averiguar para que me indique la linea exacta del error?

O que tengo que hacer para localizarla, en el NetBeans no me indica error, pero trabajando desde la web veo que no hace lo que tiene que hacer el codigo php.

No interactua con la Base de Datos o algo asi.
Hmmmm... intenta añadiendo esto al comienzo del archivo que procesa la el ingreso y la creación de usuarios:

<?php error_reporting( E_ALL );
// Resto de tu código...
<?php
// ***************************************************************************
// *
// * PHP Dynamic Trivia -- Add your own trivia file.
// * Copyright (C) 2005  Robin van de Vusse ([correo eliminado])
// * 
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// * 
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// * GNU General Public License for more details.
// * 
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
// *
// ***************************************************************************
error_reporting( E_ALL );
require_once "config.php";

if (strlen(trim($strSessionPath)) > 0)
	session_save_path($strSessionPath);

session_start();

$boolError = false;
$strAction = "";
$strMessage = "";
$strName = "";
$strPassword1 = "";
$strPassword2 = "";
$strTempDBInfo = "";

// Critical Error checking
if (empty($_SESSION))
{
	$_SESSION['name'] =  "";
	$_SESSION['message'] = "You must log in to proceed.";
	header("Location: index.php");
	exit;
}
else
{
	$strAction = $_SESSION['action'];
}

// User Error checking
if (!empty($_POST['name']))
{
	$strName = $_POST['name'];
}
elseif ($strAction == "Create New User")
{
	$strMessage = "User was NOT created!  You must specify a user. ";
	$boolError = true;	
}

// boolError checks are in there own clause instead of merging them with the nested if statement.
// Otherwise, the error message of the real error will be overwritten by the last message in the
// last error check.
if (!$boolError)
{
	if (!empty($_POST['password1']))
	{
		$strPassword1 = $_POST['password1'];
	}
	else
	{
		$strMessage = "You must specify a password.";
		$boolError = true;	
	}
}

if (!$boolError)
{
	if (!empty($_POST['password2']))
	{
		$strPassword2 = $_POST['password2'];
	}
	else
	{
		$strMessage = "You must validate your password by typing it twice.";
		$boolError = true;	
	}
}

// $boolError can be merged with if statements if there is no 'else' clause
if (!$boolError && ((strlen($strPassword1) < 4) || (strlen($strPassword1) > 32)))
{
	$strMessage = "Change was NOT successful!  Password must be no shorter than 4 characters and no longer than 32 characters.";
	$boolError = true;
}

if (!$boolError && ($strPassword1 != $strPassword2))
{
	$strMessage = "Change was NOT successful!  New password was not the same as the retyped password.";
	$boolError = true;
}

if (!$boolError)
{
	$strTempDBInfo =  DBTYPE."_pconnect";
	$conn = $strTempDBInfo($DB_HOST,$DB_USER,$DB_PASS);

	if (!$conn) 
	{
		$strTempDBInfo =  DBTYPE."_error";
		$strMessage = "Unable to connect to DB server: " . $strTempDBInfo($conn);
		$boolError = true;
	}
	else
	{
		$strTempDBInfo = DBTYPE."_select_db";
	}
}

if (!$boolError && (!$strTempDBInfo($DB_NAME)))
{
	$strTempDBInfo = DBTYPE."_error";
	$strMessage = "Unable to select DB name: " . $strTempDBInfo($conn);
	$strTempDBInfo = DBTYPE."_close";
	$strTempDBInfo($conn);
	$boolError = true;   		
}

if (!$boolError)
{
	if ($strAction == "Create New User")
	{
		$sql = "SELECT UserName FROM login WHERE UserName = '" . $strName . "'";
		$strTempDBInfo = DBTYPE."_query";
		$result = $strTempDBInfo($sql);

		if (!$result)
		{
			$strTempDBInfo = DBTYPE."_error";
			$strMessage = "Could not successfully run query ($sql) from DB: " . $strTempDBInfo($conn);
			$boolError = true;   		
		}
		else
		{
			$strTempDBInfo = DBTYPE."_num_rows";
			
			if ($strTempDBInfo($result) != 0)
			{
				$strMessage = "This user already exists.";
				$boolError = true;
			}
		}
	}	
}

if (!$boolError)
{
	if ($strAction == "Change Password")
	{
		$sql =	"UPDATE login SET UserPassword = '$strPassword1' " .
			"WHERE UserName = '$strName'";			
	}
	
	if ($strAction == "Create New User")
	{
		$strUserLastIP = $_SERVER['REMOTE_ADDR'];		
		$sql =	"INSERT INTO login ( UserName, UserPassword, UserLastIP ) " .
			"VALUES ('$strName', '$strPassword1', '$strUserLastIP')";
	}

	$strTempDBInfo = DBTYPE."_query";
	$result = $strTempDBInfo($sql);

	if (!$result) 
	{
		$strTempDBInfo = DBTYPE."_error";
		$strMessage = "Could not successfully run query ($sql) from DB: " . $strTempDBInfo($conn);
		$boolError = true;   		
	}
	else
	{
		// If $strMessage is not empty and $boolError is false then it's just a Message.
		// Otherwise, it's an Error Message.
		if ($strAction == "Change Password")
		{
			$strMessage = "Password successfully changed.";
		}
		
		if ($strAction == "Create New User")
		{
			$strMessage = "User successfully added.";
		}

		$boolError = false;
	}
	
	$strTempDBInfo = DBTYPE."_close";
	$strTempDBInfo($conn);
}

$_SESSION['message'] = $strMessage;
header("Location: options.php");	
?>

Modifique lo que me habeis dicho y queda esta clase asi.
Pero sigue sin mostrarme la linea de error.
Ah, ok... entonces hay un problema, porque necesitas limpiar el código de errores y para ello necesitarás más conocimientos. Lee en internet sobre Klogger o algún otro framework para loggin.

Saludos y suerte :).
Me indica los siguientes errores al registrar un usuario:
Notice: Undefined variable: sql in /home/u565572846/public_html/user.php on line 174

Notice: Undefined variable: sql in /home/u565572846/public_html/user.php on line 179

Warning: Cannot modify header information - headers already sent by (output started at /home/u565572846/public_html/user.php:174) in /home/u565572846/public_html/user.php on line 204
Ok, entonces revisa el archivo user.php en las líneas 174 y 179 para asegurarte de que la variable ($sql) exista. Si no se definió antes de usarse, escribe:

$sql = '';

antes de que se utilice.
Linea 174:$result = $strTempDBInfo($sql);

Linea 179:$strMessage = "Could not successfully run query ($sql) from DB: " . $strTempDBInfo($conn);

Linea 204:header("Location: options.php");

Estas son las lineas que indica erroneas pero no observo de donde puede venir el error.
El error es porque la variable $sql no está definida. Pon un @ ante cualquier función que utilice la variable $sql para suprimir las advertencias y alertas.
Esta es la parte de codigo en user.php que usa la variable $sql.

		$sql = "SELECT UserName FROM login WHERE UserName = '" . $strName . "'";
		$strTempDBInfo = DBTYPE."_query";
		$result = $strTempDBInfo($sql);

		if (!$result)
		{
			$strTempDBInfo = DBTYPE."_error";
			$strMessage = "Could not successfully run query ($sql) from DB: " . $strTempDBInfo($conn);
			$boolError = true;   		
		}
		else
		{
			$strTempDBInfo = DBTYPE."_num_rows";
			
			if ($strTempDBInfo($result) != 0)
			{
				$strMessage = "This user already exists.";
				$boolError = true;
			}
		}
	}	
}

if (!$boolError)
{
	if ($strAction == "Change Password")
	{
		$sql =	"UPDATE login SET UserPassword = '$strPassword1' " .
			"WHERE UserName = '$strName'";			
	}
	
	if ($strAction == "Create New User")
	{
		$strUserLastIP = $_SERVER['REMOTE_ADDR'];		
		$sql =	"INSERT INTO login ( UserName, UserPassword, UserLastIP ) " .
			"VALUES ('$strName', '$strPassword1', '$strUserLastIP')";
	}

	$strTempDBInfo = DBTYPE."_query";
	$result = $strTempDBInfo(@$sql);

	if (!$result) 
	{
		$strTempDBInfo = DBTYPE."_error";
		$strMessage = "Could not successfully run query ($sql) from DB: " . $strTempDBInfo($conn);
		$boolError = true;   		
	}
Buenas [:)]
Primero no te asustes por tus errores, suelen pasar, de hecho pasan.
Lo primero que tendrias que hacer es intentar limpiar esa piedra de codigo que tienes, conseguiras que sea mas legible, intuitivo y que cuando termines no se te caigan los ojos.(depura el codigo), el codigo mientres mas pequeño e intuitivo mucho mejor.
La mejor manera... crea funciones en las que englobar lineas de codigo que puedas reutilizar o que simplemente te ahorren espacio.ejempl:

<?php
$sql = "SELECT UserName FROM login WHERE UserName = '" . $strName . "'";
        $strTempDBInfo = DBTYPE."_query";
        $result = $strTempDBInfo($sql);
?>
Este cacho de codigo puedes meterlo en una funcion que se llame por ejemplo: function obtener_usuario();

una vez que tengas tu codigo mas depurado fijate en seguir varias costumbres que veo que no sigues...si aprendes aprende bien.

global $conexion;
$sql = "SELECT UserName
          FROM login 
          WHERE UserName = '" . $strName . "'";

$login = mysql_query($sql,$conexion);
verificar_consulta($sql)
return $sql;


* yo no llamaria a la variable $sql, la llamaria $consulta porque es lo que estas realizando.

*un habito recomendable para evitar dolores de cabeza es incluir la variable $conexion dentro de cualquier consulta, tienes que introducirla como una variable global pues esta declarada en un hambito global y no local que seria dentro de la funcion.

*Me imagino que si incluyes $conexion es porque la tienes creada y obviamente cerrada al final de tu php (porque por lo que te vi en tu codigo solo la generas pero no la cierras (CIERRALA).

*Despues deberias comprobar si tu consulta se realiza con exito y esto deberias de comprobarlo en todas las consultas que realices.

*verificar_consulta($UserName); es una funcion que tienes que crear con el parametro que quieres comprobar:

function verificar_consulta($sql)
{
	if(!$sql)
			{
				die("No se a podido realizar la operacion: ".mysql_error());
			}
}

*mysql_error() te devolvera el error MySQL en caso de que exista si la consulta no se realiza de ahi lo de (!$consulta.

Una vez entiendas estos primeros consejos "basicos" y repito, despiedres tu codigo podras identificar tu error muy rapidamente en el caso de que a dia de hoy aun lo tengas, si no es asi vuelve a consultar y muestra tu nuevo codigo despiedrado :-)

Perdon por poner lo de consulta, es por que se me van los dedos a su palabra correcta "donde escribo $consulta me refiero a tu $sql"
He conseguido progresos en la web, accediendo al enlace podeis entrar, ya consigo registrar,cambiar contraseña y loguearme,

ahora el problema viene en la seleccion de la base de datos de las preguntas y respuestas.

if ($boolError)
{
    $_SESSION['usernumber'] = 0;
    $_SESSION['name'] = "";
    $_SESSION['message'] = "You must log in to proceed.";
    header("Location: index.php");
    exit;
}
else
{   
    print_r($_SESSION['triviatable']);
    if (strlen(trim($_SESSION['triviatable'])) > 0)
    {
        $boolError = false;
        $intUserNumber = $_SESSION['usernumber'];
        $strName = $_SESSION['name'];
        $strTriviaTable = $_SESSION['triviatable'];
    }
    else
    {
        $boolError = true;
        $intUserNumber = 0;
        $strName = "";
        $strMessage = "No Trivia table defined.";
    }

El problema me lo da en la siguiente linea:
if (strlen(trim($_SESSION['triviatable'])) > 0)

No se de donde saca eso de 'triviatable', porque creo que es en el unico sitio que lo usa.