PHP - REGISTRAR DATOS DE EMPRESA POR USUARIO

 
Vista:
sin imagen de perfil

REGISTRAR DATOS DE EMPRESA POR USUARIO

Publicado por Sergio (1 intervención) el 08/09/2015 18:11:05
Buenas tardes a todos, estoy empezando a programar en php y tengo una duda que me esta volviendo loco. Tengo una aplicacion basado en un acceso con login en el cual un cliente accede al portal y se encuentra con tres botones los cuales uno de ellos es insertar los datos de la empresa. En la pagina donde se insertan los datos de esa empresa para guardar sus datos es datosEmpresa.php y mi duda es: Como puedo insertar cada dato de la pagina datosEmpresa.php en cada casilla de la base de datos mysql y que se guarden por usuario. Os muestro la pagina php la de conexion y la que valida el guardar datos de la empresa. A todo esto me salen estos errores en la pagina datosEmpresa.php que son:


Notice: Undefined index: id in C:\xampp\htdocs\userlitdb\datosEmpresa.php on line 10

Warning: mysql_num_rows() expects parameter 1 to be resource, string given in C:\xampp\htdocs\userlitdb\datosEmpresa.php on line 13

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\userlitdb\datosEmpresa.php on line 14




Y despues de darle a guardar los datos me salen los siguientes:

Notice: Undefined index: username in C:\xampp\htdocs\userlitdb\mod_usuario.php on line 6

Notice: Undefined index: direccion in C:\xampp\htdocs\userlitdb\mod_usuario.php on line 9

Notice: Undefined index: localidad in C:\xampp\htdocs\userlitdb\mod_usuario.php on line 10

Notice: Undefined index: pais in C:\xampp\htdocs\userlitdb\mod_usuario.php on line 11

Notice: Undefined index: sector_actividad in C:\xampp\htdocs\userlitdb\mod_usuario.php on line 14

Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\userlitdb\mod_usuario.php on line 20


datosEmpresa.php:
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
<meta charset="utf-8">
 
 <?php
session_start();
 ?>
  <?php
 
require('includes/connection.php');
 
	$id=$_GET['id'];
 
	$query="SELECT direccion, localidad, pais, telefono, nombre_empresa, sector_actividad, antiguedad, num_empleados, codigo_postal FROM usertbl WHERE id='$id'";
	$numrows=mysql_num_rows($query);
     $row=mysqli_fetch_assoc($numrows);
 
?>
 
<html>
	<head>
		<title>datos de empresa</title>
	</head>
	<body>
 
		<center><h1>Datos de empresa</h1></center>
 
		<form name="modificar_usuario" method="POST" action="mod_usuario.php">
 
			<table width="50%">
				<tr>
					<input type="hidden" name="id" value="<?php echo $id; ?>">
					<td width="20"><b>Usuario</b></td>
					<td width="30"><input type="text" name="usuario" size="25" value="<?php echo $row['direccion']; ?>" /></td>
				</tr>
				<tr>
					<td><b>Password</b></td>
					<td><input type="password" name="password" size="25" value="<?php echo $row['localidad']; ?>" /></td>
				</tr>
				<tr>
					<td><b>Email</b></td>
					<td><input type="text" name="email" size="25" value="<?php echo $row['pais']; ?>" /></td>
				</tr>
				<tr>
					<td><b>telefono</b></td>
					<td><input type="text" name="telefono" size="25" value="<?php echo $row['telefono']; ?>" /></td>
				</tr>
				<tr>
					<td><b>Nombre de la empresa</b></td>
					<td><input type="text" name="nombre_empresa" size="25" value="<?php echo $row['nombre_empresa']; ?>" /></td>
				</tr>
				<tr>
					<td><b>Sector de la actividad</b></td>
					<td><input type="text" name="sector_Actividad" size="25" value="<?php echo $row['sector_actividad']; ?>" /></td>
				</tr>
				<tr>
					<td><b>Antigüedad</b></td>
					<td><input type="text" name="antiguedad" size="25" value="<?php echo $row['antiguedad']; ?>" /></td>
				</tr>
				<tr>
					<td><b>Numero de empleados</b></td>
					<td><input type="text" name="num_empleados" size="25" value="<?php echo $row['num_empleados']; ?>" /></td>
				</tr>
				<tr>
					<td><b>Codigo postal</b></td>
					<td><input type="text" name="codigo_postal" size="25" value="<?php echo $row['codigo_postal']; ?>" /></td>
				</tr>
				<tr >
				<td></td>
		             <td ><input style="marign-left:40px"  type="submit" name="Guardar" value="Guardar" /></td>
				</tr>
			</table>
		</form>
	</body>
</html>

connection.php
1
2
3
4
5
6
7
8
9
<?php
require("constants.php");
 
	$link =mysql_connect("localhost","root","retamar");
	if($link){
		mysql_select_db("userlitdb",$link);
	}
 
	?>

mod_usuario.php
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
<?php
 
require('includes/connection.php');
 
	$id=$_POST['id'];
	$usuario=$_POST['username'];
	$password=$_POST['password'];
	$email=$_POST['email'];
    $direccion=$_POST['direccion'];
	$localidad=$_POST['localidad'];
	$pais=$_POST['pais'];
	$telefono=$_POST['telefono'];
	$nombre_empresa=$_POST['nombre_empresa'];
	$sector_actividad=$_POST['sector_actividad'];
	$antiguedad=$_POST['antiguedad'];
	$num_empleados=$_POST['num_empleados'];
	$codigo_postal=$_POST['codigo_postal'];
	$query="UPDATE usertbl SET username='$usuario', password='$password', email='$email',  direccion='$direccion',  localidad='$localidad',  pais='$pais',  telefono='$telefono',  nombre_empresa='$nombre_empresa',  sector_actividad='$sector_actividad',  antiguedad='$antiguedad',  num_empleados='$num_empleados',  codigo_postal='$codigo_postal' WHERE id='$id'";
 
	$resultado=$link->query($query);
 
?>
 
<html>
 
	<body>
		<center>
 
			<?php
				if($resultado>0){
				  echo '<script>alert("Datos guardados con éxito")</script> ';
 
				 } else{
 
				  	echo '<script>alert("Error al guardar los datos")</script> ';
 
				       }
				   ?>
		</center>
	</body>
</html>

Espero que me podais ayudar a solucionar el problema, estoy desesperadoo!!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder