amigo tengo un problema a la hora de insertar los datos en mysql con el mismo script de login.php me inserta de a 3 registro en uno solo y no se por que amigos podran ayudarme? Graciasssss!... y de que manera debo insertar los datos time?
este recibe los datos de login para checkear el ingreso y estoy agregando para poder insertar al mismo tiempo en la bd! Ayuda!
Código PHP:
<?php session_start(); ?>
<?php require_once('Connections/xtremebook.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
//funcion session start para comprobar la sesion si es correcta de
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['NOMBREUSUARIO'])) {
$loginUsername=$_POST['NOMBREUSUARIO'];
$password=$_POST['CONTRASENA'];
$MM_fldUserAuthorization ="ID";
$MM_redirectLoginSuccess = "bienvenida.php";
$MM_redirectLoginFailed = "error.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_xtreme_book, $xtremebook);
$LoginRS__query=sprintf("SELECT NOMBREUSUARIO, CONTRASENA, ID FROM registro WHERE NOMBREUSUARIO=%s AND CONTRASENA=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $xtremebook) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'ID');
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<?php
$fecha=date("Y-j-n");
$hora=time("h:i:s");
/* con Esta Funcion estoy Diciendo que me envie los datos ID FECHA Y HORA A LA BASE DE DATOS EN LA TABLA VISITAS */
mysql_query("INSERT INTO visitas (registro_ID,FECHA,HORA)
Values
('$loginStrGroup','$fecha','$hora')",$xtremebook);
?>