Skip to content

Instantly share code, notes, and snippets.

@juque
Created June 17, 2011 20:23
Show Gist options
  • Select an option

  • Save juque/1032240 to your computer and use it in GitHub Desktop.

Select an option

Save juque/1032240 to your computer and use it in GitHub Desktop.
<?php
if ( isset($_POST['enviar']) ) {
/**
* Se prepara la sentencia SQL para insertar
*/
$_sql = "
INSERT INTO hostal (
identificador,
nombre,
correo,
nacionalidad,
n_habitaciones,
n_personas,
n_dias,
fecha
)
VALUES (
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s'
)";
/**
* Se asocian las variables enviadas desde el Formulario
*/
$sql = sprintf($_sql,
$_POST['identificador'],
$_POST['nombre'],
$_POST['correo'],
$_POST['nacionalidad'],
$_POST['n_habitaciones'],
$_POST['n_personas'],
$_POST['n_dias'],
$_POST['fecha']);
$link = mysql_connect($host, $usuario, $contrasena);
$selecciona_db = mysql_select_db($db, $link);
mysql_query($sql);
$para = 'gaquev2007@alu.uct.cl';
$titulo = 'Reserva hostal';
$mensaje = 'se ha ingresado una nueva reserva al sistema 2.0!';
$cabeceras = 'From: hostal@plazalasbanderas.com' . "\r\n" .
'Reply-To: hostal@plazalasbanderas.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if( mail($para, $titulo, $mensaje, $cabeceras) ) {
echo "su mensaje ha sido enviado correctamente";
}
else {
echo "mensaje erroneo";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment