I was creating a sign-in page where all the data was coming from a MySQL database. I'm getting an error when trying to check what was the ID for that person if he was already signed up, but I'm getting an strange error on a simple select query. Here is an excerpt of the code:
Code: Select all
elseif (isset($_POST['osbtn']) && ($nome != "") && ($emailc != "") && ($work != "")){
if ($emailp != "") {
$sSQL = "SELECT * FROM attendees WHERE att_emailp = '$emailp' OR att_emailp = '$emailc' OR att_emailc = '$emailp' OR att_emailc = '$emailc';";
}
else{
$sSQL = "SELECT * FROM attendees WHERE att_emailc = '$emailp' OR att_emailc = '$emailc';";
};
$check = mysql_query($sSQL) or die (mysql_error());
$linhas_db = mysql_num_rows($check);
if (($linhas_db > 0)){
$id= mysql_fetch_array($check);
$check2 = mysql_query("SELECT * FROM classes WHERE cls_attendee_id = '$id['att_id']' AND cls_course_id = '$work'") or die(mysql_error());
$linhas_2 = mysql_num_rows($check2);
if ($linhas_2 != 0){
echo "<script> function MYALERT() {
alert('Um email já está cadastrado para este(s) curso(s).'); } MYALERT()
</script>";
}
else{
$insert = ("INSERT INTO classes SET cls_attendee_id = '$getid['att_id']', cls_course_id = '$work'") or die(mysql_error());
echo "<script> function MYALERT() {
alert('Cadastro efetuado com sucesso!'); } MYALERT()
</script>";
}
else{
$insert1 = mysql_query("INSERT INTO attendees (att_name, att_emailp, att_emailc, att_mobile, att_phonec, att_company, att_dpto, att_position) VALUES ('$nome', '$emailp', '$emailc', '$mobile', '$telefone', '$empresa', '$dpto', '$cargo')") or die(mysql_error());
$getid2 = mysql_query("SELECT * FROM attendees WHERE att_emailc = '$emailc'") or die(mysql_error());
$attid = mysql_fetch_array($getid2);
$insert2 = mysql_query("INSERT INTO classes SET cls_attendee_id = '$getid['att_id']', cls_course_id = '$work'") or die (mysql_error());
echo "<script> function MYALERT() {
alert('Cadastro efetuado com sucesso!'); } MYALERT()
</script>";
}
else{
echo "<script> function MYALERT() {
alert('Ocorreu um erro em seu cadastro. Verifique se você preencheu todos os campos obrigatórios e tente novamente.'); } MYALERT()
</script>";
};Thanks in advance.