What happens is that everything worked fine until I added codsem - > which is semester code. Now he tells me registered assistance when the student does not exist and not even.
<?php
$link = mysql_connect('localhost', 'root', '') or die('No se pudo conectar: ' . mysql_error());
echo 'Connected succedsrssfully';
mysql_select_db('controlasistencia') or die('No se pudo seleccionar la base de datos');
$query = 'SELECT * FROM asistencia';
$codes=$_POST['codes'];
$coddo=$_POST['coddo'];
$codsem=$_POST['codsem'];
$query_search = "Insert into asistencia (coddo,codsem,codes) values ('".$codes."','".$coddo."','".$codsem."')";
$query_exec = mysql_query($query_search) or die(mysql_error());
mysql_close($link);
?>
How could I do so that when a student does not exist in the table and I try to enter their assistance I get an error
Here I leave the assistance table
CREATE TABLE 'asistencia' (
'coddo' bigint(20) NOT NULL,
'codsem' bigint(20) NOT NULL,
'codes' bigint(20) NOT NULL,
'fecha' timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
And its key
ALTER TABLE 'asistencia'
ADD KEY 'codsem' ('codsem'),
ADD KEY 'codes' ('codes'),
ADD KEY 'coddo' ('coddo');