Page is a not externally linkable
helenp - 9:53 pm on Mar 20, 2012 (gmt 0)
Hi,
In beginning of february I changed host,
I know in previous host I had a higer php version than in my new host.
I have a database mysql where I insert clients booking and owner can access the intranet login in with session and they can book there property for themself.
Since some week ago simetimes I find in my bookinglist an entry without any propertyname (this comes with the session), everything else is inserted except the id (propertyname) this has happen 4 times, maybe 10% of all owners insert or less.
I been in contact with the host and he think there is a bug in my script, this script I used for years and with a higer php version.
Just checked and I am currently using php 5.2.17, in previous host I was using php 5.3
So I wonder what can make loosing the session, not always only sometimes?
If the script worked in 5.3 shouldnt it work in 5.2?
I use this script after the user filled in a form to log in using sessions: <?
include("conex/conexion.php");
$usuario = @mysql_real_escape_string($_POST['usuario']);
$pass = @mysql_real_escape_string($_POST['pass']);
$ssql = "SELECT * FROM usuarios WHERE usuario='$usuario' and pass='$pass'";
//I execute the sentence
$rs = mysql_query($ssql);
if (mysql_num_rows($rs)!=0){
//user and pass valid
//I do the session and save the dates
session_start();
$_SESSION['usuario'] = $usuario;
$_SESSION["autentificado"]= "SI";
header ("Location: loginpage_esp.php");
}else {
//If it does not exist I send them back to startpage
header("Location: span.php?errorusuario=no");
}
mysql_free_result($rs);
mysql_close($dbh);
?>
Then on all pages I start with this:
<?php
session_start();
?>
later in the script this can be seen
<?php
include("conex/conexion.php");
$usuario =$_SESSION['usuario'];
$id_property =$_REQUEST['id_property'];
?>
$casas = mysql_query("SELECT id_property, email FROM usuarios WHERE usuarios.usuario = '$usuario'", $dbh);
if ($row = mysql_fetch_array($casas)) {
To insert the booking I use this code, the property var change name as the table have diferent name for property id:
<?php
session_start();
ob_start();
?>
then:
<?php
include("conex/conexion.php");
$usuario =$_SESSION['usuario'];
$id_property =$_REQUEST['id_property'];
?>
then
$property = $_REQUEST[property];
$casas = mysql_query("SELECT id_property FROM usuarios WHERE usuarios.usuario = '$usuario'", $dbh);
$casa=mysql_result($casas,0);
$property = $casa;
$casa = str_replace("_", " ", $casa);
$property = str_replace("", "_", $property);
then process form:
check if available:
$result = mysql_query ("SELECT llegada, salida, property from bookings where ( property = '$property' ) etc...
insert booking and send automatic email:
$query1= "SELECT id_property, email FROM usuarios WHERE usuarios.usuario = '$usuario'";
$casas = $row['id_property'];
$casa2 = $row['id_property'];
$casa = $casa2;
email sent insert booking:
$query = "insert into bookings (id, llegada, tipo, tiporeserva, salida, tipo_sal, hora_llegada, hora_salida, property, cliente, reservado)" .
"values ('$id', '$llegada', '$tipo', '$tiporeserva', '$salida', '$tipo_sal', '$hora_llegada', '$hora_salida', '$property', '$cliente', '$reserv_date')";
Any help apreciated,
thanks