Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Ola,
Sou novato em php e estou com um problema que não consigo resolver se alguém puder dar uma ajuda fico muito grato.
Warning: mysql_query() expects parameter 1 to be string, resource given in C:\Program Files\EasyPHP-12.1\www\novaideiatabela\cadastro_aluno.php on line 26
___________________________________________________________
segui o código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cadastro_de_alunos</title>
</head>
<body>
<h2>Cadastro de Aluno</h2>
<?php
if (isset($_POST['submit'])) {
$nome = $_POST['nome'];
$login = $_POST['login'];
$senha = $_POST['senha'];
if (!empty($nome) && !empty($login) && !empty($senha)) {
// Connect to the database
$dbc = mysql_connect('localhost','root','','cadastro_de_alunos') or die(mysql_error());
// Write the data to the database
$query = "INSERT INTO cadastra_alunos VALUES ('$nome', '$login', '$senha')";
mysql_query($dbc, $query) or die(mysql_error());
// Confirm success with the user
echo '<p>Cadastro efetuado</p>';
echo '<p><a href="index.html"><< Voltar</a></p>';
// Clear the score data to clear the form
$nome = "";
$login = "";
$login = "";
mysql_close($dbc);
}
else {
echo '<p class="error">Por favor preencha todos os campos.</p>';
}
}
?>
<hr />
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="name">Nome:</label>
<input type="text" id="nome" name="nome" value="<?php if (!empty($nome)) echo $nome; ?>" /><br />
<label for="login">Login:</label>
<input type="text" id="login" name="login" value="<?php if (!empty($login)) echo $login; ?>" /><br />
<label for="login">Senha:</label>
<input type="password" id="senha" name="senha" value="<?php if (!empty($senha)) echo $senha; ?>" />
<hr />
<form>
<input type="submit" value="Cadastrar" name="submit" />
<input type = "button" value = "Cancelar" name = "cancelar" onClick="javascript:history.back(1)" >
</form>
</form>
</body>
</html>Carregando comentários...