Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/06/2008, 09:46
Avatar de T4ke0veR
T4ke0veR
 
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: insertar factura segun usuario de session

listo gator... fijate lo q hice

Código PHP:
<?php require_once ('includes/sesion.php');
require_once(
'conect.php'); 

$reco "-1";
if (isset(
$_SESSION['id'])) {
  
$reco $_SESSION['id'];
}
$sql="select * from clientes where id = '$reco'";
        
$sql_exec mysql_query($sql);
        
$rec mysql_fetch_array($sql_exec);
?>
<?php 
require_once('../Connections/pintor.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$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;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO factura (id, factura, tienda, monto, id_user) VALUES (%s, %s, %s, %s, $reco)",
                       
GetSQLValueString($_POST['id'], "int"),
                       
GetSQLValueString($_POST['factura'], "text"),
                       
GetSQLValueString($_POST['tienda'], "text"),
                       
GetSQLValueString($_POST['monto'], "text"),
                       
GetSQLValueString($_POST['id_user'], "int"));

  
mysql_select_db($database_pintor$pintor);

  
$Result1 mysql_query($insertSQL$pintor) or die(mysql_error());

  
$insertGoTo "gr_fact_x2.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}
?>
pero = sigue en pie mi pregunta anterior.. como lo hago con $_SESSION['id']
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...