Forum Moderators: coopster
<?
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)) { <?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')";
$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')";