Estoy nuevo pero necesito ayuda con una consulta PHP
Publicado por steban dE ABREU (3 intervenciones) el 22/02/2017 04:55:39
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<html>
<body>
<form method= "GET " />
CI:<td> <input type= "text" name= "cedula" value ="" > </td>
CLAVE:<td> <input type= "password" name= "clave" value="" > </td>
<td> <input type= "submit" name "aceptar" value="aceptar"></td>
</form>
<?php
// INGRESAR AL USUARIO
$base= mysql_connect('localhost','root','');
mysql_select_db("basico",$base) or die("No se conecto a la base de datos");
$usuario=$_GET['cedula'];
$usuario1=$_GET['clave'];
$q= mysql_query("select * from usuarios where cedula= '".$usuario."' and clave = '".$usuario1."'");
if(mysql_result($q,0)){
$result = mysql_result($q,0);
echo "Usario validado Correctamente";
?>
<h1> BIENVENIDOS </h1>
<form method= "POST">
<table border="1">
<tr>
<td>CI:<input type ="number" name="ci" value= "" > </td>
</td>
<td> Nombre:<input type = "text" name = "nom" value = " "> </td>
<td> Apellido: <input type = "text" name= "ape"value = " " > </td>
<td> Producto: <input type = "text" name= "pro" value = " " > </td>
<td> Cantidad: <input type = " number" name = "cant" value= " " > </td>
<td> Pago :<input type = "number" name = "pa" value = " " > </td>
<td> <input type = "submit" name = "co" value = "comprar " > </td>
</table>
</form>
<form method="POST"/>
Buscar CLIENTE <INPUT TYPE= "TEXT" NAME = "BU" VALUE = " " >
<input type = "submit" name="b3" value = "Buscar_Clientes" />
</form>
<form method = "POST">
<input type = "submit" name= "b1" value= " Consultar_inventario " />
</form>
<?php
//AGREGADOR DE CLIENTE
if(isset($_POST['co'])){
mysql_query("INSERT INTO clientes (CI,nombre,apellido,producto) values ('$_POST[ci]','$_POST[nom]','$_POST[ape]','$_POST[pro]')",$base);
echo " registrado correctamente ";
}
//BUSCARDOR DE CLIENTES
$buscar="";
$buscar=$_POST['BU'];
if(isset($_POST['b3'])&& $buscar !=""){
$busqueda = mysql_query("SELECT * FROM clientes WHERE nombre LIKE '%".$buscar."%'");
while($muestra=mysql_fetch_array($busqueda)){
echo '<td>'.$muestra['CI'].'</td>';
echo '<td>'.$muestra['nombre'].'</td>';
echo '<td>'.$muestra['apellido'].'</td>';
echo '<td>'.$muestra['producto'].'</td>';
}
}
else{ echo " Cliente no registrado " ;}
//CONSULTAR INVENTARIO Y AGREGAR PRODUCTO
if(
isset($_POST['b1'])){
?>
<form method="GET"/>
<td> Producto: <input type = "text" name = "product" value = " " > </td>
<td> Cantidad: <input type = "number" name = "cantid" value= " " > </td>
<td> Precio :<input type = "number" name = "preci" value = " " > </td>
</form>
<form method = "POST">
<td> <input type = "submit" name="reg" value="RegistrarInventario" > </td>
</form>
<?php
if(isset($_POST['reg'])){
mysql_query("INSERT INTO productos (nombre_producto,cantidad_producto,precio_producto) values ('$_GET[product]','$_GET[cantid]','$_GET[preci]')",$base);
echo "Inventario actualizado";
}
?>
<table border="1">
<tr>
<td colspan="3">PRODUCTOS</td>
</tr>
<td>Nombre</td>
<td>Cantidad</td>
<td>Precio</td>
</tr>
<?php
$consulta = mysql_query("select * from productos ");
while($r=mysql_fetch_array($consulta)){
?>
<td><?php echo $r[ 'nombre_producto'];?></td>
<td><?php echo $r[ 'cantidad_producto'];?></td>
<td><?php echo $r[ 'precio_producto'];?></td>
<tr>
</tr>
<?php
}
}
}
else{
echo"Usuario o pass invalida" ;
}
mysql_close($base);
?>
</body>
</html>
Este es mi codigo pero mi duda es por que en donde dice en comentario consultar inventario agregar producto no se me registra el productor en la base de datos y intente hacerlo aparte y si me funciona disculpen estoy nuevo !!
Valora esta pregunta
0