David před 10 roky
rodič
revize
e1cfbb6fec
6 změnil soubory, kde provedl 162 přidání a 40 odebrání
  1. 1 0
      .gitignore
  2. binární
      Images/productos/productos.png
  3. 62 0
      back/update.php
  4. 2 1
      css/formulario.css
  5. 91 39
      formulario.html
  6. 6 0
      js/rivets.bundled.min.js

+ 1 - 0
.gitignore

@@ -2,6 +2,7 @@ Images/graficas/*
 Images/icons/*
 Images/slider/*
 Images/thumbs/*
+Images/productos/*
 ELearning/
 Mailing/*
 uv

binární
Images/productos/productos.png


+ 62 - 0
back/update.php

@@ -0,0 +1,62 @@
+<?php
+$db = new mysqli('especificosba.com.ar', 'especificosba', 'howdoiturnthison', 'mailing');
+if($db->connect_errno > 0)
+	die('Unable to connect to database [' . $db->connect_error . ']');
+
+if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); }
+
+if ($_SERVER['REQUEST_METHOD']=="POST") {
+	$postdata = file_get_contents("php://input");
+	$request = json_decode($postdata);
+	if(!isset($request)){
+	    http_response_code(401); #Unauthorized
+	    die("no postdata");
+	}
+	
+	
+	if(!$stmt = $db->prepare("UPDATE mails_datos SET nombre=?, apellido=?,prefijo=?,telefono=?,zona=?,provincia=?,pais=?,dia=?,mes=?,infocursos=? where hash=? and mail=?"))
+		die("no pude preparar");
+	if(!$stmt->bind_param('sssssssdddss',
+							$request->nombre,$request->apellido,$request->prefijo,$request->telefono,
+							$request->zona,$request->provincia,$request->pais,
+							$request->dia,$request->mes,$request->infocursos,$request->hash,$request->email))
+	   die("errorbinding"); 
+
+	if (!$result = $stmt->execute())
+	   die("errorejec"); 
+
+	if($db->affected_rows==0){
+		echo json_encode(array("mensaje" => "no se modificaron los datos"));
+	} else {
+		echo json_encode(array("mensaje" => "ok"));
+	}
+	
+
+} elseif ($_SERVER['REQUEST_METHOD']=="GET") {
+	$stmt = $db->prepare("select nombre, apellido,prefijo,telefono,zona,provincia,pais,dia,mes,mail,infocursos from mails_datos where hash=? and mail=?");
+
+	$hash=$_GET['hash'];
+	$mail=$_GET['mail'];
+
+	$stmt->bind_param('ss', $hash,$mail);
+	$stmt->execute();
+	$stmt->bind_result($nombre,$apellido,$prefijo,$telefono,$zona,$provincia,$pais,$cumple_dia,$cumple_mes,$mail,$infocursos);
+	if($stmt->fetch()){
+		$out=array("nombre" => $nombre,
+			"apellido" => $apellido,
+			"prefijo" => $prefijo,
+			"telefono" => $telefono,
+			"zona" => $zona,
+			"provincia" => $provincia,
+			"pais" => $pais,
+			"email" => $mail,
+			"infocursos" => $infocursos,
+			"dia" => $cumple_dia,
+			"mes" => $cumple_mes);
+		echo json_encode($out);
+	} else {
+	    http_response_code(401); #Unauthorized
+		echo json_encode(array("mensaje" => "No estas en la base?"));
+	}
+}
+$db->close();

+ 2 - 1
css/formulario.css

@@ -38,6 +38,7 @@ html, body
     background-image: url("../Images/banner.jpg");
     background-size: cover;
     color: #FFF;
+	font-weight:700;
     padding-bottom: 5rem;
 }
 
@@ -85,4 +86,4 @@ input::-webkit-inner-spin-button {
 
 .xl-top-space{
 	margin-top: 30px
-}
+}

+ 91 - 39
formulario.html

@@ -6,6 +6,7 @@
 	<link type="text/css" rel="Stylesheet" href="css/normalize.css" />
 	<link type="text/css" rel="Stylesheet" href="css/skeleton.css" />
 	<link type="text/css" rel="Stylesheet" href="css/formulario.css" />
+	<script src="js/rivets.bundled.min.js"></script>
 
 </head>
 <body>
@@ -22,8 +23,8 @@
 		<div class="container max-top-space">
 		  	<div class="row">
 		  		<div class="eight columns xl-top-space">
-			    	<h1>Actualizá tus datos</h1>
-			    	<p>Estarás participando por un sorteo para ganar un set de productos de ESPECIFICOS Buenos Aires</p>
+					<h1>Actualizá tus datos</h1>
+					<p>Estarás participando por un sorteo para ganar un set de productos de ESPECIFICOS Buenos Aires</p>
 				</div>
 				<div class="four columns">
 					<img src="Images/productos/productos.png" class="productos">
@@ -39,38 +40,38 @@
 					<h4>Datos personales</h4>
 				</div>
   				<div class="row">
-    				<div class="four columns">
-      					<label for="exampleEmailInput">Nombre</label>
-      					<input class="u-full-width" type="text">
-    				</div>
+					<div class="four columns">
+	  					<label for="exampleEmailInput">Nombre</label>
+	  					<input id="nombre" class="u-full-width" type="text" rv-value='user.nombre'>
+					</div>
 
-    				<div class="four columns">
-      					<label for="exampleEmailInput">Apellido</label>
-      					<input class="u-full-width" type="text">
-    				</div>
+					<div class="four columns">
+	  					<label for="exampleEmailInput">Apellido</label>
+	  					<input id="ap" class="u-full-width" type="text" rv-value='user.apellido'>
+					</div>
   				</div>
 
   				<div class="row">
-    				<div class="four columns">
-      					<label for="exampleEmailInput">País</label>
-      					<input class="u-full-width" type="text">
-    				</div>
-    				<div class="four columns">
-      					<label for="exampleEmailInput">Provincia/Estado</label>
-      					<input class="u-full-width" type="text">
-    				</div>
-    				<div class="four columns">
-      					<label for="exampleEmailInput">Ciudad</label>
-      					<input class="u-full-width" type="text">
-    				</div>
+					<div class="four columns">
+	  					<label for="exampleEmailInput">País</label>
+	  					<input class="u-full-width" type="text" rv-value='user.pais'>
+					</div>
+					<div class="four columns">
+	  					<label for="exampleEmailInput">Provincia/Estado</label>
+	  					<input class="u-full-width" type="text" rv-value='user.provincia'>
+					</div>
+					<div class="four columns">
+	  					<label for="exampleEmailInput">Ciudad</label>
+	  					<input class="u-full-width" type="text" rv-value='user.zona'>
+					</div>
   				</div>
   				
   				<div class="row">
   					<div class=" column">
   						<label>Cumpleaños <span class="mandatory">*</span></label>
   						<div class="row">
-							<input class="two columns" type="number" min="1" max="31" placeholder="Dia (DD)"> 
-							<input class="two columns" type="number" min="1" max="12" placeholder="Mes (MM)">
+							<input class="two columns" type="number" min="1" max="31" placeholder="Dia (DD)" rv-value='user.dia'> 
+							<input class="two columns" type="number" min="1" max="12" placeholder="Mes (MM)" rv-value='user.mes'>
   						</div>
   						<div class="help"> <span class="mandatory">*</span> Durante el mes de tu cumpleaños, recibirás importantes descuentos y beneficios</div>
   					</div>
@@ -80,27 +81,27 @@
 					<h4>Contacto</h4>
 				</div>
 				<div class="row">
-    				<div class="six columns">
-      					<label for="exampleEmailInput">Email</label>
-      					<input class="u-full-width" placeholder="email@ejemplo.com" type="email">
-    				</div>
-    				<div class="six columns">
-      					<label for="exampleEmailInput">Teléfono</label>
-      					<div class="row">
-      						<input class="four columns" type="number" placeholder="Cod. Area (ej: 011)"> 
-      						<input class="eight columns" type="number">
-      					</div>
-      					
-    				</div>
+					<div class="six columns">
+	  					<label for="exampleEmailInput">Email</label>
+	  					<input class="u-full-width" placeholder="email@ejemplo.com" type="email" rv-value='user.email'>
+					</div>
+					<div class="six columns">
+	  					<label for="exampleEmailInput">Teléfono</label>
+	  					<div class="row">
+	  						<input class="four columns" type="number" placeholder="Cod. Area (ej: 011)" rv-value='user.prefijo'> 
+	  						<input class="eight columns" type="number" rv-value='user.telefono'>
+	  					</div>
+	  					
+					</div>
   				</div>
   				<hr>
   				<div class="row">
 	  				<label class="example-send-yourself-copy">
-		    			<input type="checkbox">
-		    			<span class="label-body">Quiero recibir información sobre los cursos presenciales y a distancia</span>
+						<input type="checkbox" rv-checked='user.infocursos'>
+						<span class="label-body">Quiero recibir información sobre los cursos presenciales y a distancia</span>
 	  				</label>
 	  				<div class="u-pull-right">
-	  					<input class="button-primary" value="Enviar" type="submit">
+	  					<input class="button-primary" value="Enviar" type="button" id="button">
 	  				</div>
 	  			</div>
 
@@ -114,4 +115,55 @@
 			</div>
 		</div>
 	</div>
+	<script>
+		var urlparams=window.location.search.replace("?", "").split("&");
+		var params={};
+		var xhttp = new XMLHttpRequest();
+
+		urlparams.forEach(function(elem,ind,arr) {
+			var k = elem.split("=")[0];
+			var v = elem.split("=")[1];
+			params[k]=v;
+		});
+
+		window.addEventListener('load', function() { 
+			var elems = document.querySelectorAll('input'), i;
+			document.getElementById("button").onclick = send;
+			function updateModel(){
+				for (i = 0; i < elems.length; ++i)
+					rivets.bind(elems[i], {user: user});
+			}
+			function send() {
+				xhttp.onreadystatechange = function() {
+					if (xhttp.readyState == 4) {
+					  	var data =JSON.parse(xhttp.responseText);
+						debugger;
+					}
+				};
+				xhttp.open("POST", "back/update.php", true);
+				// xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+				xhttp.send(JSON.stringify(user));
+			};
+			function get() {
+				xhttp.onreadystatechange = function() {
+				  if (xhttp.readyState == 4) {
+				  	var data =JSON.parse(xhttp.responseText);
+				  	switch (xhttp.status) {
+				  		case 200:
+				  	    	user = data;
+							user.hash=params["hash"];
+				 			updateModel();
+				  	  		break;
+				  		case 401:
+				  	  		alert(data.mensaje);
+					  	  	break;
+				  	}
+				  }
+				};
+				xhttp.open("GET", "back/update.php?mail="+params["email"]+"&hash="+params["hash"], true);
+				xhttp.send();
+			}
+			get();
+		}, false);
+	</script>
 </body>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 6 - 0
js/rivets.bundled.min.js