-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprofile.php
181 lines (137 loc) · 7.99 KB
/
profile.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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Perfil</title>
</head>
<link rel="stylesheet" href="assets/css/bootstrap.css">
<script src="assets/js/jquery-v1.10.2.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="assets/css/bootstrap.css">
<script src="assets/js/holder.js"></script>
<style>
fieldset
{
background-color: white;
border:solid 1px #CCC;
margin: 25px;
padding: 25px;
}
</style>
<body>
<?php include_once 'Includes/header.php'; ?>
<div class="contenedor">
<?
include_once "clases/db_connect.php";
session_start();
// echo "PRUEBA" . $idcliente;
if (($_SESSION['userid']) !== "") {
$idcliente = $_SESSION['userid'];
if (isset($_POST['submitted'])) {
foreach ($_POST AS $key => $value) {
$_POST[$key] = mysql_real_escape_string($value);
}
$sql = "UPDATE `cliente` SET `nombre` = '{$_POST['nombre']}' , `apellido` = '{$_POST['apellido']}' , `usuario` = '{$_POST['usuario']}' , `contrasenia` = '{$_POST['contrasenia']}' , `fecha_nac` = '{$_POST['fecha_nac']}' , `correo` = '{$_POST['correo']}' , `tel` = '{$_POST['tel']}' WHERE `idcliente` = '$idcliente' ";
mysql_query($sql) or die(mysql_error());
echo (mysql_affected_rows()) ? "Edited row.<br />" : "Nothing changed. <br />";
echo "<a href='list.php'>Regresar</a>";
}
$row = mysql_fetch_array(mysql_query("SELECT * FROM `cliente` WHERE `idcliente` = '$idcliente' "));
?>
<div class="jumbotron">
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#Perfil">Perfil</a></li>
<li class=""><a href="#Historial">Historial de compras</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="Perfil">
<div class="row">
<div class="col-md-12">
<form action='' method='POST'>
<fieldset>
<div><b>Nombre:</b><br /><input type='text' name='nombre' value='<?= stripslashes($row['nombre']) ?>' /></div>
<div><b>Apellido:</b><br /><input type='text' name='apellido' value='<?= stripslashes($row['apellido']) ?>' /></div>
<div><b>Usuario:</b><br /><input type='text' name='usuario' value='<?= stripslashes($row['usuario']) ?>' /></div>
<div><b>Contrasenia:</b><br /><input type='text' name='contrasenia' value=""/></div>
<div><b>Fecha Nac:</b><br /><input type='text' name='fecha_nac' value='<?= stripslashes($row['fecha_nac']) ?>' /></div>
<div><b>Correo:</b><br /><input type='text' name='correo' value='<?= stripslashes($row['correo']) ?>' /></div>
<div><b>Tel:</b><br /><input type='text' name='tel' value='<?= stripslashes($row['tel']) ?>' /></div>
<div><input type='submit' value='Guardar Cambios' /><input type='hidden' value='1' name='submitted' /></div>
</fieldset>
</form>
<? } ?>
</div>
</div>
</div>
<div class="tab-pane " id="Historial">
<div class="row">
<div class="col-md-12">
<style>
table
{
background: white;
}
.sub-tabla
{
border-radius: 10px;
display: block;
margin-left: 125px;
padding-left: 50px;
}
</style>
<h3>Historial de compras</h3>
<?
include_once '../clases/db_connect.php';
echo "<table class='bordered table-bordered table-condensed' >";
echo "<tr>";
echo "<td><b>Codigo Compra</b></td>";
echo "<td><b>Fecha de Compra</b></td>";
echo "<td><b>Cantidad Comprada</b></td>";
echo "<td><b>Total</b></td>";
echo "</tr>";
$result = mysql_query("SELECT * FROM `compra` where id_u=$idcliente") or trigger_error(mysql_error());
while ($row = mysql_fetch_array($result)) {
foreach ($row AS $key => $value) {
$row[$key] = stripslashes($value);
}
echo "<tr>";
echo "<td valign='top'>" . nl2br($row['cod_compra']) . "</td>";
echo "<td valign='top'>" . nl2br($row['fecha']) . "</td>";
echo "<td valign='top'>" . nl2br($row['cantidad_p']) . "</td>";
echo "<td valign='top'>" . nl2br($row['total']) . "</td>";
echo "</tr>";
}
echo "</table>";
echo "<div class='sub-tabla'>";
echo "<table class='bordered table-bordered table-condensed' >";
echo "<tr>";
echo "<td><b>Nombre del Producto</b></td>";
echo "<td><b>Fecha</b></td>";
echo "</tr>";
$result = mysql_query("SELECT * FROM `detalles_compra` where id_u=$idcliente") or trigger_error(mysql_error());
while ($row = mysql_fetch_array($result)) {
foreach ($row AS $key => $value) {
$row[$key] = stripslashes($value);
}
echo "<tr>";
echo "<td valign='top'>" . nl2br($row['nombre_p']) . "</td>";
echo "<td valign='top'>" . nl2br($row['fecha']) . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
?>
</div>
</div>
</div>
</div>
<script>
$('#myTab a').click(function(e) {
e.preventDefault();
$(this).tab('show');
});
</script>
</div>
</div>
</body>
</html>