Everything is fine, but the moment I press the save button I get the following error:
Fatal error: Call to a member function save () on a non-object in C: \ wamp \ www \ form \ form.php on line 18.
I leave the codes:
<?php
include ('libreria/motor.php');
$regis = Registros::mostrar();
$registros=new Registros();
if ($_POST){
//$registros ->ID=$_POST['ID'];
$registros ->Nombre=$_POST['txtNombre'];
$registros ->No_control=$_POST['txtNoControl'];
$registros ->Sexo=$_POST['txtSexo'];
$registros ->Direccion=$_POST['txtDireccion'];
$registros ->Correo=$_POST['txtCorreoElectronico'];
$registros ->Telefono=$_POST['txtTelefono'];
$registros ->Celular=$_POST['txtCelular'];
$registros ->Carrera=$_POST['txtCarrera'];
$registros ->Pocedencia=$_POST['txtEscuela'];
$Registros ->guardar();
header("Location:formulario.php");
}
?>
<html>
<head>
<title>INSTITUTO TECNOLOGICO DE ALTAMIRA</title>
</head>
<body>
<form method= "post" action="">
<fieldset>
<legend>REGISTRO DE ESTUDIANTES</legend>
<table>
<tr>
<td>Nombre:
<input type="text" name="txtNombre"/>
</td>
</tr>
<tr>
<td>No Control:
<input type="text" name="txtNoControl"/>
</td>
</tr>
<tr>
<td>Sexo:
<input type="radio" name="txtSexo" value="Femenino" />Femenino
<input type="radio" name="txtSexo" value="Masculino" />Masculino
</td>
</tr>
<tr>
<td>Direccion:
<input type="text" name="txtDireccion"/>
</td>
</tr>
<tr>
<td>Correo Electronico:
<input type="text" name="txtCorreoElectronico"/>
</td>
</tr>
<tr>
<td>Telefono:
<input type="text" name="txtTelefono"/>
</td>
</tr>
<tr>
<td>Celular:
<input type="text" name="txtCelular"/>
</td>
</tr>
<tr>
<td>Carrera:
<select name="txtCarrera">
<option>Agronomia</option>
<option>Administracion</option>
<option>Biologia</option>
<option>Industrial</option>
<option>Sistemas</option>
</select>
</td>
</tr>
<tr>
<td>Escuela De Pocedencia:
<select name="txtEscuela">
<option>ABRAHAM LINCOLN</option>
<option>Cbtis105</option>
<option>Cetis78</option>
<option>CONALEP</option>
<option>ITACE ALTAMIRA</option>
<option>PREPA ALTAMIRA</option>
</select>
</td>
</tr>
<tr>
<td>
<button method="post" type="submit">Agregar</button>
</td>
</tr>
</table>
</fieldset>
<hr>
<fieldset>
<legend>ALUMNOS REGISTRADOS</legend>
<table border="1">
<thead>
<tr>
<th>ID</th>
<th>NOMBRE</th>
<th>No DE CONTROL </th>
<th>SEXO</th>
<th>DIRECCION</th>
<th>CORREO ELECTRONICO</th>
<th>TELEFONO</th>
<th>CELULAR</th>
<th>CARRERA</th>
<th>ESCUELA DE PROCEDENCIA</th>
</tr>
</thead>
<tbody>
<?php
foreach ($regis as $registros){
echo"
<tr>
<td>$registros[ID]</td>
<td>$registros[Nombre]</td>
<td>$registros[No_control]</td>
<td>$registros[Sexo]</td>
<td>$registros[Direccion]</td>
<td>$registros[Correo]</td>
<td>$registros[Telefono]</td>
<td>$registros[Celular]</td>
<td>$registros[Carrera]</td>
<td>$registros[Procedencia]</td>
</tr>
";
}
?>
</tbody>
</table>
</fieldset>
</form>
</body>
</html>
CLASS REGISTROS.PHP
class registros {
public $ID;
public $Nombre;
public $No_control;
public $Sexo;
public $Direccion;
public $Correo;
public $Telefono;
public $Celular;
public $Carrera;
public $Procedencia;
function guardar(){
$sql=" insert into registros (Nombre,No_control,Sexo,Direccion,Correo,Telefono,Celular,Carrera,Procedencia);
values('($this=>Nombre)','($this=>No_control)','($this=>Sexo)','($this=>Direccion)','($this=>Correo)','($this=>Telefono)','($this=>Celular)','($this=>Carrera)','($this=>Procedencia)')";
mysql_query($sql);
}
static function mostrar(){
$sql="select * from registros";
$rs=mysql_query($sql);
$regis=array();
while($fila=mysql_fetch_assoc($rs)>0){
$regis[]=$fila;
}
return $regis;
CLASS connection.php
<?php
class Conexion{
public $enlace;
function __construct(){
$this -> enlace=mysql_connect(DB_HOST,DB_USER,DB_PASS);
mysql_select_db(DB_NAME, $this -> enlace);
}
function __destruct(){
mysql_close($this->enlace);
}
}