3
File that records:
<html>
<head>
<meta charset="utf-8">
<title>cadastrando...</title>
</head>
<body>
<?php
$host = "localhost";
$user = "root";
$pass = "";
$banco = "cadastro";
$conexao=@mysql_connect($host,$user, $pass) or die(mysql_error());
mysql_select_db($banco) or die(mysql_error());
?>
<?php
$nome=$_POST['Nome'];
$sobrenome=$_POST ['Sobrenome'];
$pais=$_POST['pais'];
$estado=$_POST['estado'];
$cidade=$_POST['cidade'];
$email=$_POST['Email'];
$senha=$_POST['senha'];
$sql = mysql_query("INSERT INTO usuarios(nome, sobrenome, pais, estado, cidade, email, senha)
VALUES('$nome', '$Sobrenome', '$pais', '$estado', '$cidade', '$Email', '$senha')");
echo "Cadastro efetuado com sucesso!!!"
?>
</body>
</html>
Form
<html>
<head>
<meta charset="utf-8">
<title>Sistema de Cadastro</title>
</head>
<body>
<form name="signup" method="post" action="cadastrando.php">
nome: <input type="text" name="nome" /> </br></br>
sobrenome: <input type="text" name="Sobrenome" /> </br></br>
Pais: <input type="text" name="pais" /> </br></br>
Estado: <input type="text" name="estado" /> </br></br>
Cidade: <input type="text" name="cidade" /> </br></br>
E-mail: <input type="text" name="Email" /> </br></br>
Senha: <input type="password" name="senha" /> </br></br>
<input type="submit" value="Cadastrar" />
</body>
</html>
First adjust the names of variables in the Index: ('$name', '$surname', '$parents', '$state', '$city', '$email', '$password')
– Malaba
Tip: If you are populating all fields in the table with the information, you can exchange
insert into usuarios(nome, sobrenome, pais, estado...) values(...)by justINSERT INTO USUARIOS VALUES(....). So your query gets more simplified, since you don’t need to specify the fields, since you will insert data in all of them.– Victor Alencar Santos