PHP - Como puedo modificar datos

 
Vista:
sin imagen de perfil

Como puedo modificar datos

Publicado por miguel (4 intervenciones) el 09/04/2014 17:50:04
Buenas la cuestion esta en que En mi MVC tengo un formulario el cual me permite modificar datos de comprador como nombre apellido y esas cosas los datos de los mismos son traidos de la base de datos y los muestra pero no me activa el campo de modificacion les anexo los controladores que uso los modelos y las vistas

Controlador:

<?php
class profileController extends Controller{
private $_profile;

public function __construct(){
parent::__construct();
$this->_profile = $this->loadModel('login');
$this->getTemplate('User');
}

public function index(){
Session::acceso();

$this->getLibrary('protocol/goHttps');

$user = new User();
$user->setEmail(Session::get('email'));

$this->_view->info = $this->_profile->getInfo($user);

$this->_view->renderizar('index', 'parcial', 'profile');
}

public function update(){
$user = new User();
$user->setUser(Session::get('email'));
$user->setClave($_POST['c']);
$user->setNombre($_POST['n']);
$user->setApellido($_POST['a']);
$user->setCodHome($_POST['ch']);
$user->setTelefonoC($_POST['tC']);
$user->setCodMovil($_POST['cm']);
$user->setTelefonoM($_POST['tM']);
$user->setMunicipio($_POST['m']);
$user->setSector($_POST['sector']);
$user->setCalle($_POST['calle']);
$user->setCasa($_POST['casa']);
$user->setMapa($_POST['mapa']);

$a = $this->_profile->updateUserInfo($user);

$this->_view->renderizar('index', 'parcial', 'profile');
}
}
?>

Modelo

<?php
class loginModel extends Model{
public function __construct(){
parent::__construct();
}

public function getInfo(User $usuario){

$datos = $this->_db->query("SELECT user.*, user_add.*
FROM t_orion_core_user as user, t_orion_core_user_address as user_add
WHERE user.email = '".$usuario->getEmail()."'
AND user.email = user_add.user
AND user_add.status = 0");
return $datos->fetch();
}

public function insertUser(User $user){
$pass = Hash::getHash('sha1', $user->getClave(), HASH_KEY);
$sql="INSERT INTO t_orion_core_user (id, username, password, email, ci, first_name, last_name, sex, home_phone, movil_phone, cod_home_p, cod_movil_p)VALUES(null, '".$user->getEmail()."', '".$pass."', '".$user->getEmail()."', '".$user->getCedula()."', '".$user->getNombre()."', '".$user->getApellido()."', '".$user->getSexo()."', '".$user->getTelefonoC()."', '".$user->getTelefonoM()."', '".$user->getCodHome()."', '".$user->getCodMovil()."')";
$sql1="INSERT INTO t_orion_core_user_address VALUES(null, '".$user->getMunicipio()."', '".$user->getSector()."', '".$user->getCalle()."', '".$user->getCasa()."', '".$user->getMapa()."', '0', '".$user->getEmail()."')";
if ($this->_db->query($sql)){
if ($this->_db->query($sql1)){
return true;
}else{
return false;
}
}else{
return false;

}



}

public function updateUserInfo(User $user){
// Datos personales
$this->_db->query("UPDATE t_orion_core_user
SET first_name = '".$user->getNombre()."', last_name = '".$user->getApellido()."', home_phone = '".$user->getTelefonoC()."', movil_phone = '".$user->getTelefonoM()."', cod_movil_p = '".$user->getCodMovil()."', cod_home_p = '".$user->getCodHome()."'
WHERE email = '".$user->getEmail()."'");
// Contraseña
if($user->getClave() != ''){
$pass = Hash::getHash('sha1', $user->getClave(), HASH_KEY);
$this->_db->query("UPDATE t_orion_core_user SET password = '".$pass."' WHERE email = '".$user->getEmail()."'");
}
// Dirección
$this->_db->query("INSERT INTO t_orion_core_user_address VALUES(null, '".$user->getMunicipio()."', '".$user->getSector()."', '".$user->getCalle()."', '".$user->getCasa()."', '".$user->getMapa()."', '1' ,'".$user->getUser()."')");
}
public function getReC(User $user){
$datos = $this->_db->query("SELECT * from t_orion_core_user where email='".$user->getEmail()."' ");

return $datos->fetch();

}
}

?>

Vista

<div id="cuerpo_edicion" class="fondoscuro2">
<table width="542" border="0" align="center">
<tbody><tr>

<td colspan="2" class="Estilo7">&nbsp; <span class="formulario2 texdatos" style="text-align: center; font-size:14px; font-family: Arial, Helvetica, sans-serif;">Favor verifique los datos que desea modificar.</span></td>
</tr>
<tr>
<td width="240"><div class="formulario2 texdatos" style="text-align:right" >Cedula<span class="Estilo9">(*)<span class="dos">:</span></span></div></td>
<td width="292"><input name="ci" type="text" class="textbox span3" onchange="mayusculas(this)" value="<?= $this->info['ci']; ?>" onkeypress="return acceptNum(event)" disabled="" style=" margin-bottom:2px; margin-top:2px">
<input name="cig" type="hidden" value="">
<input name="emailReg" type="hidden" value="">
</td>
</tr>

<tr>
<td height="40" style=" padding-top:5px"><div style="text-align:right"><span class="formulario2 texdatos">Sexo<span class="Estilo9">(*)<span class="dos">:</span></span> </span></div></td>
<td>
<input type="hidden" value="<?= $this->info['sex']; ?>" id="sexControl">
<input class="input-mini" type="radio" disabled="" <?= ($this->info['sex'] == 'M') ? 'checked="checked"' : ''; ?>>
<span class="Estilo7" style="font-size: 12px">Masculino</span><span class="Estilo7">
<input class="input-mini" type="radio" disabled="" <?= ($this->info['sex'] == 'F') ? 'checked="checked"' : ''; ?>>
<span style="font-size: 12px">Femenino</span></span>
</td>
</tr>


<!-- Para control -->
<input type="hidden" id="username" value="<?= $this->info['username']; ?>">
<td height="40" style=" padding-top:5px"><div style="text-align:right" class="formulario2 texdatos"> Nombre<span class="Estilo9"> (*)<span class="dos">:</span></span></div></td>
<td>
<input name="nombre" id="nombre" type="text" class="textbox span3 TextStandard letter_only" value="<?= $this->info['first_name']; ?>" onchange="mayusculas(this)" style=" margin-bottom:10px; margin-top:2px">
</td>
</tr>


<tr>
<td height="40" style=" padding-top:5px"><div style="text-align:right"><span class="formulario2 texdatos">Apellido <span class="Estilo9">(*)<span class="dos">:</span></span></span></div></td>
<td>

<input name="apellido" id="apellido" type="text" class="textbox span3 TextStandard letter_only" value="<?= $this->info['last_name']; ?>" onchange="mayusculas(this)" style=" margin-bottom:10px; margin-top:2px">
</td>
</tr>

<tr>

<td height="40" style=" padding-top:5px"><div style="text-align:right"><span class="formulario2 texdatos">E-Mail<span class="Estilo9"> (*)<span class="dos">:</span></span></span></div></td>
<td>

<input name="email" type="text" class="textbox TextStandard span3" value="<?= $this->info['email']; ?>" onchange="mayusculas(this)" disabled="" style=" margin-bottom:2px; margin-top:2px">

</td>
</tr>


<tr>
<td height="40" style=" padding-top:5px"><div style="text-align:right"><span class="formulario2 texdatos">Modificar Contraseña<span class="Estilo9"><span class="dos">:</span></span></span></div></td>
<td>
<input class="input-mini activeChangeKey" type="radio" name="OPCONTRA" value="SI">
<span class="Estilo7"><span style="font-family: 'Trebuchet MS', 'Lucida Sans Unicode', Arial, sans-serif; font-size: 12px;">SI
<input class="input-mini inactiveChangeKey" type="radio" name="OPCONTRA" value="NO">
NO

</span></span>
</td>
</tr>


<tr>
<td style=" padding-top:10px"><div style="text-align:right"><span class="formulario2 texdatos">Clave<span class="Estilo9">(*)</span><span class="dos">:</span> </span></div></td>
<td>
<input name="pass" id="clave" type="password" class="password TextStandard span3" value="" onchange="mayusculas(this)" disabled="" style=" margin-bottom:-20px; margin-top:0px" >
</td>
</tr>


<tr>
<td height="50" style=" padding-top:5px"><div style="text-align:right"><span class="formulario2 texdatos">Repita la Clave<span class="Estilo9">(*)<span class="dos">:</span></span> </span></div></td>
<td>

<input name="repass" id="clave2" type="password" class="password TextStandard span3" value="" onchange="mayusculas(this)" disabled="" style=" margin-bottom:-10px; margin-top:0px">

</td>
</tr>


<tr>
<td height="40" style=" padding-top:5px"><div style="text-align:right"><span class="formulario2 texdatos">Telefono Casa<span class="Estilo9">(*)</span>:</span></div></td>
<td>
<select class="span2" name="opCasa" id="cC" style="height:30px; width:90px">

<option value="<?= $this->info['cod_home_p']; ?>" selected=""><?= $this->info['cod_home_p']; ?></option>
<?php if($this->info['cod_home_p'] != 212): ?>
<option value="212">(212)</option>
<?php endif; ?>
</select>
<input name="tcasa" id="tCasa" type="text" maxlength="7" class="num_only textbox TextStandard span9" value="<?= $this->info['home_phone']; ?>">
</td>
</tr>



<tr>
<td height="40"><div style="text-align:right"><span class="formulario2 texdatos">Telefono Movil<span class="Estilo9">(*)</span>:</span></div></td>
<td>
<select name="opMovil" class="span2" id="cM" style="height:30px; width:90px">

<option value="<?= $this->info['cod_movil_p']; ?>" selected=""><?= $this->info['cod_movil_p']; ?></option>
<option value="414">(414)</option><option value="424">(424)</option><option value="412">(412)</option><option value="416">(416)</option><option value="426">(426)</option>
</select>
<input name="tmovil" id="tMovil" type="text" maxlength="7" class="num_only textbox TextStandard span9" value="<?= $this->info['movil_phone']; ?>">

</td>
</tr>

<input name="theDate" type="hidden" value="2002/08/08">
<!--<tr>
<td colspan="2"><div align="right"><span class="formulario2">Fecha de Nacimiento.:</span></div></td>
<td colspan="3">

<!-- <input name="theDate" type="text" class="textbox span3" value="" readonly="readonly">
<!-- -->
<!-- <input name="theDate" type="text" class="textbox span3" value="" readonly="readonly">


<!-- <a href="#" onClick="displayCalendar(document.forms.theDate,'yyyy/mm/dd',this)"> <img src="images/calendario.png" alt="Mostrar Calendario"></a></td>
</tr> -->
<tr>
<td height="31"><div align="right"><span class="Estilo10" style="font-size: 14px; font-family: 'Yanone Kaffeesatz', sans-serif;">Campos obligatorios (*)</span></div></td>
<td><span class="Estilo10" style="font-size: 14px; font-family: 'Yanone Kaffeesatz', sans-serif;"></span></td>
</tr>

</tbody></table>
</div>



</div>

<!--Desde aqui el conotenedor del mapa -->

<div id="Contenedor_mapa" class="fondoscuro3">
<div id="contenedormap">
<div id="titulomap">
<center><table width="509" border="0">
<tr>
<td width="503" height="73">
<div id="titulo">Localizar mi ubicación actual </div></td>
</tr>
</table></center>
</div>
<div id="informacion">

<div id="direccioninfo">
<b class="textomap"><span style="font-size: 18px">Direcci&oacute;n</span></b><b class="textomap">:</b>
<div id="address" class="textomap"></div>
</div>

<div id="info" class="textomap" style=" width:1000px">


</div>

</div>
</div>
<div id="mapas">
<div id="mapCanvas"></div>
<div id="mapCanvas2" ></div>
<div id="permitir">
<center>
<table width="100%" border="0" background="public/img/carrito/background/fondo.png">
<tr>
<td><div style="font-family: Arial, Helvetica, sans-serif; color: #FFF; text-align:center; font-weight:bold " class="fondoscuro3">Arrastre el indicador <img src="public/img/map/icono.png"> hacia su nueva ubicaci&oacute;n exacta.</div></td>
</tr>
<tr >
<td ><div class=" fondoclaro2"><center><input name="button" type="button" class="btn btn-warning" id="button" style="height:28px; margin-right:20px; margin-top:10px; margin-bottom:10px" onClick="MM_showHideLayers('Contenedor_mapa','','hide','mapas','','hide','mapCanvas','','hide','mapCanvas2','','hide')" value="Aceptar">
<input type="button" name="button" id="button" class="btn btn-warning" value="Localiza mi ubicaci&oacute;n actual" onClick="localizame()" style="height:28px; margin-top:10px; margin-bottom:10px"></center></div></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>

</center>
</div>
</div>

<div id="infoPanel">

<div id="markerStatus" style="visibility:hidden" class="textomap"><i> </i></div>
</div>

</div>


<!--Hasta aqui el conotedenor del mapa -->
</form>

</body></html>

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