Click here to Skip to main content
16,020,626 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi everyone! I have a problem in My system when I send My data to My database, and I do not know why it happens, by the way my queries I have to change them to parameterized (THE ERROR IS IN MY QUESTION 😉)

This is my code(THE ERROR IT´S IN THE LAST LINE):

<?php 
  include ("conex.php");
  //logeo
 
session_start();
include("conex.php"); 
if(isset($_POST['ingre'])){
  
  $name = $_POST["name"];
  $password = $_POST["pass"];

  $sql = "SELECT COUNT(*) as contar FROM usuario  WHERE name ='$name' AND pass ='$password'";
   $consult=mysqli_query($conn,$sql);
   $arreglo=mysqli_fetch_array($consult);
   
  if($arreglo['contar']> 0) {
	  $_SESSION['usuario']=$name;
	 echo "<script>alert('Bienvenido: $name'); window.location='home.php'</script>";
  }else{
	  echo "<script>alert('Los datos estan mal'); window.location='login.php'</script>";
  }
 
  //Registrar
$name = $_POST["name"];
$apellido = $_POST["apec"];
$dad = $_POST["namep"];
$mom = $_POST["namem"];
$tipeCI = $_POST["tipeid"];
$ci = $_POST["ci"];
$phone = $_POST["te"];
$correo = $_POST["email"];
$add = $_POST["dirre"];
$day = $_POST["diana"];
$gradoI = $_POST["gradoin"];
$esC = $_POST["estado"];
$sex = $_POST["sex"];
$pass = $_POST["pass"];
  
if(isset($_POST["butt"]))
{
	$sqlgrabar = "INSERT INTO usuario(name,last,nameDad,nameMom,tipoIdentificacion,identificacion,telefono,email,address
	,born,rango,estadoC,sex,pass)
	values ('$name','$apellido','$dad','$mom','$tipeCI','$ci','$phone','$correo','$add','$day','$gradoI','$esC',
	'$sex','$pass')"; 
	
	//EVITAR REPETIDO
	 $veri_correo=mysqli_query($conn,"SELECT * FROM usuario WHERE email='$correo'");
	 $veri_pass=mysqli_query($conn,"SELECT * FROM usuario WHERE pass='$pass'");
 
	  if(mysqli_num_rows($veri_correo) > 0){
		  echo '<script>window.location="dise/errorEgistro.php";</script>';
		  
		  exit();
	  }
	  
	  if(mysqli_num_rows($veri_pass) > 0){
		   echo '<script>window.location="dise/errorEgistro.php";</script>';
		  exit();
	  }
	
	if(mysqli_query($conn,$sqlgrabar))
	{
		echo "<script> alert('Felicidades el usuario fue registrado con exito: $name'); window.location='login.php' </script>";
	}else 
	{
		echo "Error: ".$sqlgrabar."<br>".mysqli_error($conn);
	}
}

?>  


What I have tried:

I tried some thing but nothing, I Am a little NOOB, and I don't why the error happened
Posted
Updated 22-Jan-23 0:03am

1 solution

This is the second time you have asked the same question, on the same code: the answer does not change just because we don't "sort it all out for you" and hand you "working code" on a plate...

As I said last time, the error is because you have mismatched brackets somewhere, and the system can only tell that when it reaches the end of the code and finds you added one more "open curly brackets" than matching "close curly brackets". And since it has no idea where it should have been, it can't "put it in for you" - and neither can we!
If you count the number of "{" in your code you get 8.
If you count the number of "}" in your code you get 7.
Most people can count that high; most people can tell that 7 and 8 are different numbers.

Because your indentation is not consistent, we can't even tell from that what you intended to write, and that means we have no idea where the missing "}" should be ...
If you wrote that code, you should have a good idea where things should be. So indent that code consistently to match what you intended when you wrote it and it should be obvious to you where the missing bracket should be.

And that code, and probably your whole app, is still wide open to SQL Injection ...
 
Share this answer
 
Comments
XEmmanuel21 20-Nov-21 11:44am    
Very thanks! Done

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900