/
add_data.php
203 lines (174 loc) · 5.69 KB
/
add_data.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
include_once 'dbMySql.php';
$con = new DB_con();
$formatos=array('.jpg','.png','.gif','.ico');
// data insert code starts here.
if(isset($_POST['btn-save']))
{
$nombre=$_FILES['archivo']['name'];
$nombreTmp=$_FILES['archivo']['tmp_name'];
$exte=substr($nombre, strrpos($nombre,'.'));
if (in_array($exte,$formatos)) {
if (move_uploaded_file($nombreTmp,"imagenes/$nombre")) {
//echo '<script> alert(" Exito al ingresar su imagen"); </script>';
//echo "<script> window.location='index.php'; </script>";
}
}
else{
echo '<script> alert(" Error al ingresar la imagen"); </script>';
echo "<script> window.location='usuarios.php'; </script>";
}
$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$email= $_POST['email'];
$lugar = $_POST['lugar'];
$coordenada_x= $_POST['coordenada_x'];
$coordenada_y= $_POST['coordenada_y'];
$imagen = $nombre;
$res=$con->insert($fname,$lname,$email,$lugar,$coordenada_x,$coordenada_y,$imagen);
if($res)
{
?>
<script>
alert('Usuario registrado con exito...');
window.location='usuarios.php'
</script>
<?php
}
else
{
?>
<script>
alert('error en el registro de usuario...');
window.location='usuarios.php'
</script>
<?php
}
}
// data insert code ends here.
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Data</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
</head>
<body>
<?php include ("navbar.php"); ?>
<center>
<div id="body" >
<div id="content" class="content" style="margin-top:50px;">
<form method="post" enctype="multipart/form-data" style="width:125%;">
<table align="center" class="table1">
<tr>
<th class="title">DATOS</th>
<th class="title"> MAPA</th>
</tr>
<tr >
<td class="row">NOMBRE:<input type="text" name="first_name" placeholder="Nombre" required /></td>
<TD ROWSPAN=6 class="map">
<?php
$lat = "-17.36853187650009";
$lng = "-66.16338881969455";
$pos = "-17.36853187650009,-66.16338881969455";
$valor = explode(',',$pos);
echo "
<div id='info'>".$pos."</div>
<div id='googleMap'></div>
<div id='respuesta'></div>";
?>
</TD>
</tr>
<tr>
<td>APELLIDOS:<input type="text" name="last_name" placeholder="Apellido" required /></td>
</tr>
<tr>
<td>CORREO ELECTRONICO:<input type="text" name="email" placeholder="Email" required /></td>
</tr>
<tr>
<td>LUGAR:<input type="text" name="lugar" placeholder="Lugar" required /></td>
</tr>
<tr>
<td>COORDENADA X:<input id="coordenada_x" type="text" name="coordenada_x" placeholder="Coordenada x"value=" <?php echo "$valor[0]"; ?>" required /></td>
</tr>
<tr>
<td>COORDENADA Y:<input id="coordenada_y" type="text" name="coordenada_y" placeholder="Coordenada y" value=" <?php echo "$valor[1]"; ?>" required /></td>
</tr>
<tr>
<td>
FOTO:
<input type="file" name="archivo" >
<!--<input class="uploadfile" type="button" value="Seleccionar imagen" onclick="document.getElementById('botonFileReal').click();" style=""> -->
</tr>
<tr>
<td>
<button type="submit" name="btn-save"><strong>Guardar</strong></button>
</td>
</tr>
</table>
</form>
</div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
lat = "<?php echo $lat; ?>" ;
lng = "<?php echo $lng; ?>" ;
var map;
function initialize() {
var myLatlng = new google.maps.LatLng(lat,lng);
var mapOptions = {
zoom: 7,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("googleMap"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
draggable:true,
animation: google.maps.Animation.DROP,
web:"Localización geográfica!",
icon: "marker.png"
});
google.maps.event.addListener(marker, 'dragend', function(event) {
var myLatLng = event.latLng;
lat = myLatLng.lat();
lng = myLatLng.lng();
document.getElementById('info').innerHTML = [
lat,
lng
].join(', ');
var x=document.getElementById("coordenada_x").value=[lat].join(', ');
var y=document.getElementById("coordenada_y").value=[lng].join(', ');
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
$("#enviar").click(function() {
var url = "cargar.php";
$("#respuesta").html('<img src="cargando.gif" />');
$.ajax({
type: "POST",
url: url,
data: 'lat=' + lat + '&lng=' + lng,
success: function(data)
{
$("#respuesta").html(data);
}
});
});
});
</script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</center>
<div style="width:100%; float:left;">
<?php include ("footer.php"); ?>
</div>
</body>
</html>