My database is changing the surname by the registered name and the email does not appear

3

File that writes:

<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>
    
asked by anonymous 05.10.2015 / 20:56

1 answer

3

The variables in php are case sensitive, uppercase is different from lowercase, so: $nome is different from $Nome . The values sent by the form must be the same as%,%, of% is different from $_POST

If it is started already started badly, the mysql_ * functions have already been discontinued and will soon be removed, use a modern API to connect as the database as MYSQLi or PDO.

I suggest you leave all the names in the box,

form

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>        

cadastra.php

//código omitido
$nome = mysql_real_escape_string($_POST['nome']);
$sobrenome = mysql_real_escape_string($_POST ['sobrenome']);
$pais = mysql_real_escape_string($_POST['pais']);
$estado = mysql_real_escape_string($_POST['estado']);
$cidade = mysql_real_escape_string($_POST['cidade']);
$email = mysql_real_escape_string($_POST['email']);
$senha = mysql_real_escape_string($_POST['senha']);

$query = "INSERT INTO usuarios(nome, sobrenome, pais, estado, cidade, email, senha)
          VALUES('$nome', '$Sobrenome', '$pais', '$estado', '$cidade', '$email', '$senha')";

$sql = mysql_query($query) or die(mysql_error())

Recommended reading:

MySQL vs PDO - Which is the most recommended to use?

Why should not we use functions of type mysql_ *?

How to convert a MYSQL connection to MYSQLI?

Using PDO is the safest way to connect to a DB with PHP?

    
05.10.2015 / 21:05