Ayuda con este problema
Publicado por Jorge (16 intervenciones) el 21/11/2016 04:09:24
Buenas noches amigos, soy estudiante y estoy comenzando con la programación y me gustaría que me ayudaran. Me sale el siguiente error al tratar de ejecutar el siguiente código para realizar un login sencillo
Notice: Undefined variable: con in C:\xampp\htdocs\proyecto\login.php on line 15
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\proyecto\login.php on line 15
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\proyecto\login.php on line 16
Notice: Undefined variable: con in C:\xampp\htdocs\proyecto\login.php on line 29
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\proyecto\login.php on line 29
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\proyecto\login.php on line 30
Notice: Undefined variable: con in C:\xampp\htdocs\proyecto\login.php on line 15
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\proyecto\login.php on line 15
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\proyecto\login.php on line 16
Notice: Undefined variable: con in C:\xampp\htdocs\proyecto\login.php on line 29
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\proyecto\login.php on line 29
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\proyecto\login.php on line 30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
//include("connect_db.php");
//$miconexion = new connect_db;
session_start();
require("conexion.php");
$username=$_POST['email'];
$pass=$_POST['pass'];
//la variable $mysqli viene de connect_db que lo traigo con el require("connect_db.php");
$sql2=mysqli_query($con,"SELECT * FROM clientes WHERE email='$username'");
if($f2=mysqli_fetch_assoc($sql2)){
if($pass==$f2['pasadmin']){
$_SESSION['id']=$f2['id'];
$_SESSION['nombre']=$f2['nombre'];
echo '<script>alert("BIENVENIDO ADMINISTRADOR")</script> ';
echo "<script>location.href='admin.php'</script>";
}
}
$sql=mysqli_query($con,"SELECT * FROM clientes WHERE email='$username'");
if($f=mysqli_fetch_assoc($sql)){
if($pass==$f['password']){
$_SESSION['id']=$f['id'];
$_SESSION['nombre']=$f['nombre'];
header("Location: index2.php");
}else{
echo '<script>alert("CONTRASEÑA INCORRECTA")</script> ';
echo "<script>location.href='index.php'</script>";
}
}else{
}
?>
Valora esta pregunta


0