<?
			session_name( "SYNCRO" );
			$v1="user_id";
			$v2="user_name";
			$v3="user_auth";
			session_register($v1,$v2,$v3);
			session_start();

 if ( empty( $user_auth ) || !isset($peli_id) || 
	( !isset($p_status) && !isset($peli_name) )
    )
 {
  echo "<META CONTENT=\"0; URL=index.htm\" HTTP-EQUIV=\"REFRESH\">";
 }else {
  $conexion = mysql_connect( 'localhost', 'syncro_users', '29dic2001' ) OR die("No puedo conectar");
  $id = mysql_select_db( 'SYNCRO', $conexion ) OR die("No puedo abrir Base de Datos");

  if ( isset( $p_status ) )
  {
    if ( strcmp( $accion, "insertar" )==0 )
    {
     // INSERTAMOS EN LA LISTA PERSONAL...
     $sql_upd = "INSERT INTO pelis_user (user, peli, status) VALUES($user_id,$peli_id,'$p_status')";
     $res = mysql_query( $sql_upd, $conexion ) OR die("No puedo realizar las Inserciones Personales<br>$sql_upd<br>".mysql_error($conexion));
     $ins_upd = true;
    } else
    if ( strcmp( $accion, "editar" )==0 )
    { 
     $sql_upd = "UPDATE pelis_user SET status='$p_status' WHERE user = $user_id AND peli = $peli_id";
     $res = mysql_query( $sql_upd, $conexion ) OR die("No puedo realizar las Actualizaciones Personales<br>$sql_upd<br>".mysql_error($conexion));
     $ins_upd = true;
    }
  }
  if ( !isset($accion) )
  {
    $res = mysql_query( "SELECT * FROM pelis_user WHERE user='$user_id' AND peli='$peli_id'", $conexion ) OR die("No puedo consultar si tienes esta peli.<br>$sql_upd<br>".mysql_error($conexion));       
    if ( mysql_num_rows( $res ) != 0 ) $accion = "editar";
  }
  mysql_close($conexion);
?>
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 <title>SYNCRO: Listado de peliculas</title>
 <link href="syncro.ico" rel="SHORTCUT ICON">
 <link rel="stylesheet" type="text/css" href="syncro.css" body="syncro.css">
 </head>
 
 <body bgcolor="#57A44D"> 

<?
if ( isset( $accion )  ) 
 echo "<form action='gestion-amispelis.php?peli_id=$peli_id&peli_name=$peli_name&accion=editar' method='POST'>";
else 
 echo "<form action='gestion-amispelis.php?peli_id=$peli_id&peli_name=$peli_name&accion=insertar' method='POST'>";
?>

    <div align="center"><center><table border="1" cellpadding="0"
    cellspacing="0" width="600" bgcolor="#427B42"
    bordercolor="#000000" bordercolordark="#000000"
    bordercolorlight="#000000">
        <tr>
            <td>
<? 
   if ( isset( $ins_upd ) )
   {
    echo "<center>La pelicula &quot;<a href='gestion-pelisp.php?peli_id=$peli_id'>$peli_name</a>&quot; ha sido agregada � modificada de tu lista personal";
   }else {
?>
 	<div align="center"><center><table border="0"
            cellpadding="2" cellspacing="0">
                <tr>
                    <td width="250"><br>
                    Agregar la pel�cula &quot;<a href="gestion-pelisp.php?peli_id=<? echo $peli_id ?>"><? echo $peli_name ?></a>&quot;, a
                    mi listado personal con el siguiente estado:<p><!--webbot
                    bot="HTMLMarkup" startspan --><p style='text-align:center;margin-right:5.0pt'><!--webbot
                    bot="HTMLMarkup" endspan -->Estado: <select
                    name="p_status" size="1">
                        <option selected>OK</option>
                        <option>PEDIR</option>
                    </select><!--webbot bot="HTMLMarkup"
                    startspan --></p><!--webbot bot="HTMLMarkup"
                    endspan --></p>
                    </td>
                    <td><input type="image" name="I3"
                    src="images/enviar.gif" alt="ENVIAR"
                    align="bottom" border="0" width="20"
                    height="71"></td>
                </tr>
            </table>
            </center></div>
<?
 }
?>
</td>
        </tr>
    </table>
    </center></div>
</form>
 </body>
 </html>
<?
 }
?>