problems sending the data to the database [closed]

1

I am now entering the programming part with mysql and php , and I am in doubt on the part of calling the database. can you help me?

The codes I wrote:

<html>
<head>
<title> sistema de cadastro</title>
</head>

<body>
<form method="get="action="cadastrando.php">
nome: <input type="text" name="name"/> <b></b>
sobre nome: <input type="text" name="sobrenome"/><b> </b>
pais: <input type="text" name="pais"/> <b></b>
estado:<input type="text" name="estado"/> <b></b>
idade: <input type="text" name="cidade"/> <b></b>
e-mail: <input type="text" name="email"/> <b></b>
senha: <input type="password" name="senha"/> <b></b>
<input type="submit" value=""/>
</form>

</body>
</html>

///////////////////////////////////////////////////////////////////////////

<html>
<head>
<title> cadastramento</html>
</head>
<body>
<?php
$host ="localhost";
$user = "root";
$pass = "";
$banco= "cadastramento";
$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 usaname(NOME,SOBRENOME,PAIS,ESTADO,CIDADE,EMAIL,SENHA) values('$NOME','$SOBRENOME','$PAIS','$ESTADO','$CIDADE','$EMAIL','$SENHA')");
?>

</body>
</html>
    
asked by anonymous 09.09.2015 / 21:05

1 answer

3

The problem is that the variables defined are in lowercase and the passwords in the insert in uppercase, php is case sensitive for variables, so $nome is different from $NOME .

The global super name is $_POST in same caps.

The shipping method is defined in form

<form method="get="action="cadastrando.php">

Use $_GET to get and $_POST to post, I suggest you change method to post.

<?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 usaname(NOME,SOBRENOME,PAIS,ESTADO,CIDADE,EMAIL,SENHA) values('$nome','$sobrenome','$pais','$estado','$cidade','$email','$senha')") or die(mysql_error());

Recommended reading:

Why should not we use functions of type mysql_ *?

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

    
09.09.2015 / 21:20