Im trying to make a form where it appears a lists of events so the user can chosee.
this events are inside a table and its supposed to record wich user chose wich event.
The query seems to work, I seem to have a problem with the radiobutton.
Please help me, im driving my self crazy
here`s the code :
[php]
<head>
<title> Inscribirse a un nuevo evento </title>
</head>
<body>
<h1> Seleccione el evento al que se quiere inscribir </h1>
<?php
$link = mysql_connect("localhost", "root");
if ($link) {
mysql_select_db("intranet_cpsi", $link);
}
$idlogin_user = 3 ;
$query= "select * from evento";
$resultado= mysql_query($query,$link);
$aux_cod_event =9 ;
//echo $aux_cod_event;
//mysql_query("INSERT INTO usuario_evento VALUES('3','3') ");
echo " <table border = '1' ><tr><td>Codigo de evento</td><td>Comienzo</td><td>Fin</td><td>Costo</td><td>Nombre del evento</td><td>Seleccion de evento</td></tr>";
echo " <form method = 'POST'> " ;
while($dato=mysql_fetch_array($resultado))
{
echo "<tr>";
echo "<td>".$dato["cod_event"]."</td>" ;
echo "<td>".$dato["comienzo"]."</td>" ;
echo "<td>".$dato["fin"]."</td>" ;
echo "<td>".$dato["coste"]."</td>" ;
echo "<td>".$dato["nombre_event"]."</td>" ; ?>
<input type='radio' name='aux_cod_event'<?php if (isset($aux_cod_event) && $aux_cod_event == $dato["cod_event"] ) echo "checked"; ?> value = '$dato["cod_event"]'> </td>" ;
<?php
echo "</tr>";
}
echo "</table>";
echo $aux_cod_event."<br>";
echo "<input type='submit' name='submit' value='Registrarme'/> " ;
echo "</form>";
if (isset($_POST['submit']))
{
$aux_cod_event = $_POST['$aux_cod_event'];
echo $aux_cod_event."<br>";
mysql_query("INSERT INTO usuario_evento VALUES('$idlogin_user','$aux_cod_event')");
mysql_close($link);
echo 'Se ha registrado exitosamente ';
}
?>
</body>
[/php]