How can I use the $ _SESSION, to send data to my corresponding account

0
Fatal error: No se puede volver a asignar la variable auto-global.

Hello, well the problem comes to me when sending data to a database to the field that belongs to the user.

This way I put this in my files to not lose the variable. Example:

session_start ();

I extract and show the user that in this case is the email:

echo "Nombre de usuario recuperado de la variable de sesión:".$_SESSION['correo'];

As I change or convert that variable $_SESSION to use it and that the user sends the data to its corresponding field in the BD and update fields of your account your personal data etc please I need your help in advance Thank you!

<?php
session_start();
?>
<?php
echo "Nombre de usuario recuperado de la variable de sesión:".$_SESSION['correo'];
?>
<?php

$codigo=$_POST['vcod'];
$mysql_usuario = "root";
$mysql_password = "Engineringg96";
$mysql_host = "localhost";
$mysql_database = "bdutc";


$conexion = mysql_connect($mysql_host, $mysql_usuario, $mysql_password, true);


mysql_select_db($mysql_database, $conexion) || die('No pudo conectarse: '.mysql_error());


$consulta="select idprestamo,idficha,mk.idpersona,mk.nombre,mk.appat,mk.apmat,mk.correo,mk.matricula,ml.idlibro,ml.clas, ml.titulo, ml.autor, ml.editorial, ml.fecha, ml.asignatura, ml.isbn, cc.idcategoria,
cc.categoria, cc.idcategoria,ca.idcarrera,ca.carrera, cu.idcuatrimestre,cu.cuatrimestre,cp.idplantel, cp.plantel, mp.idperiodico,mp.periodico,mr.idrevistas, mr.revistas,mi.idpresta
   from  dficha ta 


   LEFT JOIN mlibro ml ON ta.idlibro=ml.idlibro
   LEFT JOIN ccategoria cc ON ta.idcategoria=cc.idcategoria
   LEFT JOIN ccarrera ca ON ta.idcarrera=ca.idcarrera
   LEFT JOIN ccuatrimestre cu ON ta.idcuatrimestre=cu.idcuatrimestre
   LEFT JOIN cplantel cp ON ta.idplantel=cp.idplantel
   LEFT JOIN mperiodico mp ON ta.idperiodico=mp.idperiodico
   LEFT JOIN mrevistas mr ON ta.idrevistas=mr.idrevistas
     LEFT JOIN mpersona mk ON ta.idprestamo=mk.idpersona



   where idficha='".$codigo."'";

$resultado = mysql_query($consulta, $conexion) or die(mysql_error());

echo  "<table border='1' cellpadding='10'>\n";
echo  "
<th>Clas</th>
<th>Titulo</th>
<th>Autor</th>
<th>Editorial</th>
<th>Fechadepublicacion</th>
<th>Asignatura</th>
<th>ISBN</th>
<th>Categoria</th>
<th>Carrera</th>
<th>Cuatrimestre</th>
<th>Plantel</th>
<th>Periodico</th>
<th>Revista</th>
<th>Cantidad Ejemplares</th>
<th>Designar
FechaInicio/Fin</th>

</tr>\n";
while($fila = mysql_fetch_assoc($resultado)){
echo  "<tr>

      <td>".$fila["clas"]."</td>
      <td>".$fila["titulo"]."</td>
      <td>".$fila["autor"]."</td>
      <td>".$fila["editorial"]."</td>
      <td>".$fila["fecha"]."</td>
      <td>".$fila["isbn"]."</td>
      <td>".$fila["asignatura"]."</td>
      <td>".$fila["categoria"]."</td>
      <td>".$fila["carrera"]."</td>
      <td>".$fila["cuatrimestre"]."</td>
      <td>".$fila["plantel"]."</td>
      <td>".$fila["periodico"]."</td>
      <td>".$fila["revistas"]."</td>

      <td><form method='post' action='pedir.php'> 
      <input type='text' name='idpresta' maxlength='1'>
      <input type='date' name='inicio'>
      <input type='date' name='fin'>
      <input type='hidden' name='idlibro' value='".$fila["idlibro"]."'>
      <input type='hidden' name='idcategoria' value='".$fila["idcategoria"]."'>
      <input type='hidden' name='idcarrera' value='".$fila["idcarrera"]."'>
      <input type='hidden' name='idcuatrimestre' value='".$fila["idcuatrimestre"]."'>
      <input type='hidden' name='idplantel' value='".$fila["idplantel"]."'>
      <input type='hidden' name='idperiodico' value='".$fila["idperiodico"]."'>
      <input type='hidden' name='idrevistas' value='".$fila["idrevistas"]."'>
      <input type='hidden' name='idficha' value='".$fila["idficha"]."'>
      <input type='hidden' name='idpersona' value='".$fila["idpersona"]."'>
      <input type='hidden' name='idprestamo' value='".$fila["idprestamo"]."'>
      <input type='hidden' name='idpresta' value='".$fila["idpresta"]."'>
      <input type='hidden' name='correo' value='".$fila["correo"]."'>

      <input type='submit' name='generar' value='Generar Ficha'>
      </form></td>
   </tr>\n";
    }
echo  "</table>\n"; 



?>

Good Look This is a query that throws me a search engine that I have, in this case I search for a book and when I click I send this data to a field in the database and there it is fine if they are sent without problem, what is not done is how to do that for example:

In my database I have related tables I have one where

there are fields that the user to register fill my table is this

tabla: mpersona->campos->
idpersona:1
idtpersona:2
idsancion:0
idplantel:2
correo:[email protected]
contraseña:karla123

and is related to

this other table: dprestamo

idprestamo:1
idpresta:
idpersona:1
fechainicio:
fechafin:

and it fills up automatically when the mpersona is filled, a idprestamo is generated and the idpersona I pass it with a php statement.

And that's where I want to know how to program the variable $_SESSION or how can I make that variable have a value and can the user make an insertion of data in its corresponding field in the database?

    
asked by Kevin Duarte 29.05.2017 в 02:33
source

0 answers