inserir dados em duas tabelas no mysql erro urgente
ola galera estou com o seguinte problema,
estou usando um script antigo e quando o usuario se cadastra tem que savar os daos em duas tabelas no mysql: na tabel usuarios e na tabela alunos
a usuario tem id com primaria e e-mail e cpf com indice
a tabela alunos tem id como primaria e matricula como indice
problema: estava tudo funcionando certinho , agora derrepente quando tento se cadastrar da erro e insere apenas na tabela usuario
preciso de ajuda nisso sou iniciante
SEGUE O CODIGO DO ARQUIVO:
<?php
include './link1.php';
//inicia sessao
if (!isset($_SESSION)) {
session_start();
}//variaveis do formulario
$textoCaptcha = $_POST['textcaptcha'];
$nome = $_POST['nome'];
$email = $_POST['email'];
$cpf = ($_POST['cpf'] == '')?'NULL':"'". $_POST['cpf'] ."'";
$senha = $_POST['senha'];
$celular = $_POST['celular'];
$telefone = ($_POST['telefone']=='')?'NULL':"'" . $_POST['telefone'] . "'";
$nascimento = explode("/", $_POST['data_nasc']);
$nascimento = $nascimento[2] . "-" . $nascimento[1] . "-" . $nascimento[0];
$matricula = ($_POST['matricula'] == '')?'NULL':"'" . $_POST['matricula'] . "'";
$uf = $_POST['uf'];
$cidade = $_POST['cidade'];
//$bairro = $_POST['bairro'];
$endereco = $_POST['endereco'];
if($_SESSION["captcha"] != $textoCaptcha){
header("Location: index.php?inscricao&error");
exit;
}else{
$id = date("ymdHis");
$emailAtivo = 'F';
//consulta em usuario
$sqlUsuario = "INSERT INTO sch_usuarios (id, nome, email, cpf, senha, celular, telefone, d_nascimento, tipo) VALUES ("
. "'$id', '$nome', '$email', $cpf, '$senha', '$celular', $telefone, '$nascimento', '1')";
$buscausuario = mysql_query($sqlUsuario);
if(!$buscausuario){
header("Location: index.php?inscricao&error");
exit;
}
//consulta em aluno
$sqlAluno = "INSERT INTO sch_alunos (id, matricula, uf, cidade, bairro, endereco, email_ativo) VALUES ("
. "'$id', $matricula, '$uf', '$cidade', '$endereco', 'F')";
$buscaAluno = mysql_query($sqlAluno);
if(!$buscaAluno){
header("Location: index.php?inscricao&error");
exit;
}
$_SESSION['UserId'] = $id;
$_SESSION['UserNome'] = $nome;
$_SESSION['UserEmail'] = $email;
$_SESSION['UserTipo'] = '1';
$_SESSION['typeStudent'] = '1';
$_SESSION['typeOrganizer'] = '0';
$_SESSION['typeAppraiser'] = '0';
header("Location: platformuser.php");
}
?>Discussão (6)
Carregando comentários...