PHP - VALIDAR OPCION DE SELECT SI ES UNA OPCION QUE ABRA VENTANA Y ENVIE CORREO

 
Vista:

VALIDAR OPCION DE SELECT SI ES UNA OPCION QUE ABRA VENTANA Y ENVIE CORREO

Publicado por JEGCR (1 intervención) el 23/08/2017 23:17:46
Hola he estado por días trabajando en un pequeña encuesta y no me funciona, al darle click al boton de enviar, me llega los datos por correo pero deseo de igual forma quiero abra una de las paginas que tenemos en html, dependiendo la opción seleccionada dentro del Select de ingreso sera la página a utilizar. cuento con dos páginas,
sorteoganador.html y sorteonoganador.html

NOTA la estoy trabajando en dentro de Wordpress:
Este es mi codigo dentro de Wordpress:

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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<script
 src="https://code.jquery.com/jquery-2.2.4.js"
 integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI="
 crossorigin="anonymous"></script>
 
<style>
.modalDialog {
 position: fixed;
 font-family: Arial, Helvetica, sans-serif;
 top: 0;
 right: 0;
 bottom: 0;
 left: 0;
 background: rgba(0, 0, 0, 0.8);
 z-index: 99999;
 opacity:0;
 -webkit-transition: opacity 400ms ease-in;
 -moz-transition: opacity 400ms ease-in;
 transition: opacity 400ms ease-in;
 pointer-events: none;
}
.modalDialog:target {
 opacity:1;
 pointer-events: auto;
}
.modalDialog > div {
 width: 85%;
 position: relative;
 margin: 7% auto;
 padding: 5px 20px 13px 20px;
 border-radius: 10px;
 background: #fff;
 background: -moz-linear-gradient(#fff, #999);
 background: -webkit-linear-gradient(#fff, #999);
 background: -o-linear-gradient(#fff, #999);
}
 
.close {
 background: #606061;
 color: #FFFFFF;
 line-height: 25px;
 position: absolute;
 right: -12px;
 text-align: center;
 top: -10px;
 width: 24px;
 text-decoration: none;
 font-weight: bold;
 -webkit-border-radius: 12px;
 -moz-border-radius: 12px;
 border-radius: 12px;
 -moz-box-shadow: 1px 1px 3px #000;
 -webkit-box-shadow: 1px 1px 3px #000;
 box-shadow: 1px 1px 3px #000;
}
.close:hover {
 background: #00d9ff;
}
.btn {
 background: #515151;
 background-image: -webkit-linear-gradient(top, #515151, #515151);
 background-image: -moz-linear-gradient(top, ##515151, #515151);
 background-image: -ms-linear-gradient(top, #515151, #515151);
 background-image: -o-linear-gradient(top, #515151, #515151);
 background-image: linear-gradient(to bottom, #515151, #515151);
 -webkit-border-radius: 5;
 -moz-border-radius: 5;
 border-radius: 10px;
 color: #ffffff;
 font-size: 22px;
 padding: 10px 10px 10px 10px;
 text-decoration: none;
}
 
.btn:hover {
 background: #ffffff;
 border-color: #515151;
 color: #515151;
 text-decoration: none;
}
.has-error{
 border-color:red;
}
.row{
 display:block;
 margin-top:17px;
}
.col-md-4{
width:31.3%;
margin-left: 1%;
float:left;
margin-top:10px;
}
 
.col-md-12{
width:96.9%;
margin-left: 1%;
float:left;
margin-top:10px;
}
 
.form-control{
width:100%;
}
@media only screen and (max-width:728px){
.col-md-4,col-md-12{
width:95%;
margin-left:2.5%;
display:block;
margin-top:10px;
}
 
}
 </style>
<h1><div align="center">¡Mucha suerte!</div></h1>
<div style="display:none;" id="mensaje-success" align="center">
 <p align="center">Ya estas participando en estos momentos, confirma en la página que aparecera en unos momentos.</p>
</div>
<form id="prospectform">
<div class="row">
 <div class="col-md-4">
 <label for="nombre"><h5>1.- Nombre completo</h5></label>
 <input type="text" class="form-control" id="nombre">
 </div>
 <div class="col-md-4">
 <label for="celular"><h5>2.- Teléfono celular</h5></label>
 <input type="text" class="form-control" id="celular">
 </div>
 <div class="col-md-4">
 <label for="email"><h5>3.- Correo electrónico</h5></label>
 <input type="text" class="form-control" id="email">
 </div>
</div>
<div class="row">
 <div class="col-md-4">
 <label for="edad"><h5>4.- Edad</h5></label>
 <select class="form-control" id="edad">
<option value="<28">Menos de 28 años</option>
<option value="28">28 años</option>
<option value="29">29 años</option>
<option value="30">30 años</option>
<option value="31">31 años</option>
<option value="32">32 años </option>
<option value="33">33 años</option>
<option value="34">34 años</option>
<option value="35">35 años</option>
<option value="36">36 años</option>
<option value="37">37 años</option>
<option value="38">38 años</option>
<option value="39">39 años</option>
<option value="40">41 años</option>
<option value="42">42 años</option>
<option value="43">43 años</option>
<option value="44">44 años</option>
<option value="45">45 años</option>
<option value="46">46 años</option>
<option value="47">47 años</option>
<option value="48">48 años</option>
<option value="49">49 años</option>
<option value="50">50 años</option>
<option value="51">51 años</option>
<option value="52">52 años</option>
<option value="53">53 años</option>
<option value="54">54 años</option>
<option value="55">55 años</option>
<option value="56">56 años</option>
<option value="57">57 años</option>
<option value="58">58 años</option>
<option value="59">59 años</option>
<option value="60">60 años</option>
<option value="61">61 años</option>
<option value="62">62 años</option>
<option value="63">63 años</option>
<option value="64">64 años</option>
<option value="65">65 años</option>
<option value="66">66 años</option>
<option value="67">67 años</option>
<option value="69">69 años</option>
<option value="69">69 años</option>
<option value="70">70 años</option>
<option value=">70">Mayor de 70 años</option>
</select>
 </div>
 <div class="col-md-4">
 <label for="salud"><h5>5.- Que tan importante es la salud de usted y su familia </h5></label>
 <select class="form-control" id="salud">
 <option value="nada_importante">Nada Importante</option>
 <option value="importante">Importante</option>
 <option value="muy_importante">Muy Importante</option>
 </select>
 </div>
 <div class="col-md-4">
 <label for="ocupacion"><h5>6- Ocupación</h5></label>
 <input type="text" class="form-control" id="ocupacion">
 </div>
 </div>
<div class="row">
 <div class="col-md-4">
 <label for="civil"><h5>7.- Estado Civil</h5></label>
 <select class="form-control" id="civil">
 <option value="soltero(a)">Soltero(a)</option>
 <option value="casado(a)">Casado(a)</option>
 <option value="divorciado(a)">Divorciado(a)</option>
 <option value="union libre">Union Libre</option>
 <option value="viudo(a)">Viudo(a)</option>
 </select>
 </div>
</div>
<div class="row">
 <div class="col-md-4">
 <label for="hijos"><h5>8.- Cuantos hijos tiene</h5></label>
 <select class="form-control" id="hijos">
 <option value="0">0</option>
 <option value="1">1</option>
 <option value="2">2</option>
 <option value="3">3</option>
 <option value="4">4</option>
 <option value="5">5</option>
 <option value="6_o_mas">6 o más</option>
 </select>
 </div>
 <div class="col-md-4">
 <label for="ingreso"><h5>9.- Su ingreso mensual familiar es de</h5></label>
 <select class="form-control" id="ingreso" name="ingreso">
 <option value="Menos de $9,999">Menos de $9,999</option>
 <option value="10000_a_14999">$10,000 a $14,999</option>
 <option value="15000_a_19999">$15,000 a $19,999</option>
 <option value="20000_a_24999">$20,000 a $25,999</option>
 <option value="25000_a_mas">$25,000 a Más</option>
 </select>
 </div>
</div>
<div class="row">
 <div class="col-md-12">
<label for="padece"><h5>10.- Padece Usted de: </h5>(para seleccionar dos o más opciones utilice la tecla ctrl y click en los padecimientos que tenga)</label>
<select class="form-control" name="padece[]" multiple size="9" id="padece">
<option value="hipertencion">Hipertención</option>
<option value="diabetes">Diabetes</option>
<option value="dolores">Dolores</option>
<option value="mareos">Mareos</option>
<option value="sobrepeso">Sobrepeso</option>
<option value="insomnio">Insomnio</option>
<option value="fatiga">Fatiga</option>
<option value="ninguna_enfermedad">Ninguna Enfermedad</option>
</select>
</div>
<div class="col-md-12">
<center><button type="click" class="btn" id="sendEmail">Participar »</button></center>
</div>
</div>
</form>
 
 
<script>
 
var postmsg = {};
var nombre;
var celular;
var edad;
var email;
var salud;
var ocupacion;
var padece;
var civil;
var hijos;
var ingreso;
var valid = true;
 
$( "#sendEmail" ).click(function() {
 
nombre = $('#nombre').val();
celular = $('#celular').val();
edad = $('#edad').val();
email = $('#email').val();
salud = $('#salud').val();
ocupacion = $('#ocupacion').val();
padece = $('#padece').val();
civil = $('#civil').val();
hijos = $('#hijos').val();
ingreso = $('#ingreso').val();
 
 
//Form validation
if(nombre.length==0){
 valid = false;
 $('#nombre').addClass('has-error');
}else{
 $('#nombre').removeClass('has-error');
};
if(celular.length==0){
 valid = false;
 $('#celular').addClass('has-error');
}else{
 $('#celular').removeClass('has-error');
};
if(email.length==0){
 valid = false;
 $('#email').addClass('has-error');
}else{
 $('#email').removeClass('has-error');
};
if(ocupacion.length==0){
 valid = false;
 $('#ocupacion').addClass('has-error');
}else{
 $('#ocupacion').removeClass('has-error');
};
 
 
 
if(valid){
postmsg.nombre = nombre;
postmsg.celular = celular;
postmsg.edad = edad;
postmsg.email = email;
postmsg.salud = salud;
postmsg.ocupacion = ocupacion;
postmsg.padece = padece;
postmsg.civil = civil;
postmsg.hijos = hijos;
postmsg.ingreso = ingreso;
 
url_email_contacto_prospect = "http://flavor-home.com/email_contacto_prospect.php";
console.log(url_email_contacto_prospect)
$.post(url_email_contacto_prospect,postmsg).done(function( data ) {
 console.log(data)
 if(data!="fail"){
 console.log(postmsg.email)
 $('#prospectform')[0].reset();
 $('#mensaje-success').show();
 
 }else{
 alert('Hubo un error al enviar el email, por favor comunícate con nuestro equipo de soporte');
 }
});
}else{
 alert('Debes llenar todos los campos resaltados como requeridos');
 valid = true;
};
return false;
});
 
</script>



Este es mi código dentro del 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
<?php
header('Access-Control-Allow-Origin: *');
// One destinatary
  $to = "flavorhomemx@gmail.com";
  $nombre = $_POST["nombre"];
  $celular = $_POST["celular"];
  $edad = $_POST["edad"];
  $email = $_POST["email"];
  $salud = $_POST["salud"];
  $ocupacion = $_POST["ocupacion"];
  $padece = $_POST["padece"];
  $civil = $_POST["civil"];
  $hijos = $_POST["hijos"];
  $ingreso = $_POST["ingreso"];
$padecimiento = implode(', ', $padece);
 
 
if ($ingreso == 'Menos de  $9,999') {
  	window.open('http://flavor-home.com/sorteonoganador.html' ) ;
}
	else{
	window.open('http://flavor-home.com/sorteoganador.html' ) ;
};
 
// title
$title = "Nueva solicitud de Prospectacion dentro del programa Tu Salud Tu Vida";
 
// message
$message_admin = '
<html>
<head>
  <title>'.$title.'</title>
  <meta charset="utf-8">
</head>
<body style="font-size:12px;">
<div><img src="http://flavor-home.com/flavor_logo.png" /></div>
<hr>
<center><h3>'.$title.'</h3></center>
<center><h3>'.$nombre.'['.$email.'] ha enviado una solicitud de prospectacion dentro del programa de Tu Salud Tu Vida con los siguientes datos:</h3></center>
<center>
<table>
    <tr>
        <center><h3>Detalle de la solicitud de contacto de prospectacion</h3></center>
    </tr>
    <tr>
        <th style="color:blue;">
          <b>Nombre:</b>
        </th>
      <th>
          '.$nombre.'
        </th >
    <th style="color:blue;">
          <b>Email:</b>
        </th>
      <th>
          '.$email.'
        </th>
    </tr>
  <tr>
        <th style="color:blue;">
          <b>Telefono celular:</b>
        </th>
      <th>
          '.$celular.'
        </th>
    <th style="color:blue;">
          <b>Edad:</b>
        </th>
      <th>
          '.$edad.'
        </th>
    </tr>
  <tr>
        <th style="color:blue;">
          <b>Correo electronico:</b>
        </th>
      <th>
          '.$email.'
        </th>
    </tr>
    <tr>
        <th style="color:blue;">
          <b>Que tan importante es la salud de usted y su familia :</b>
        </th>
      <th>
          '.$salud.'
        </th>
    <th style="color:blue;">
          <b>Ocupaci�n:</b>
        </th>
      <th>
          '.$ocupacion.'
        </th>
    </tr>
  <tr>
        <th style="color:blue;">
          <b>Usted padece de:</b>
        </th>
      <th>
          '.$padecimiento.'
	   </th>
    <th style="color:blue;">
          <b>Estado Civil:</b>
        </th>
      <th>
          '.$civil.'
        </th>
    </tr>
  <tr>
        <th style="color:blue;">
          <b>N�mero de Hijos:</b>
        </th>
      <th>
          '.$hijos.'
        </th>
  </tr>
   <tr>
        <th style="color:blue;">
          <b>Ingreso Mensual Familiar:</b>
        </th>
      <th>
          '.$ingreso.'
        </th>
  </tr>

</table>
</center>
</body>
<footer align="justify" style="font-size:10px;">
<br><br>
<hr>
<a href="http://flavor-home.com">Flavor Home</a> 2017 <small>todos los derechos reservados</small>
</footer>
</html>
';
 
// Content - type
$headings  = 'MIME-Version: 1.0' . "\r\n";
$headings .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
// headings
$headings .= 'From: noreply@flavor-home.com' . "\r\n";
 
 
// Send
if(mail($to, $title, $message_admin, $headings)){
 
}
else{
	echo "fail";
};
if ($_POST['ingreso'] == 'Menos de  $9,999') {
  	window.open('http://flavor-home.com/sorteonoganador.html' ) ;
}
	else{
	window.open('http://flavor-home.com/sorteoganador.html' ) ;
};


Espero y me ayuden
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
Imágen de perfil de facundo

VALIDAR OPCION DE SELECT SI ES UNA OPCION QUE ABRA VENTANA Y ENVIE CORREO

Publicado por facundo (185 intervenciones) el 24/08/2017 13:47:53
mm tal vez en el "action" del form tengas que poner una variable, y esa variable tomaria el valor del selected seleccionado.
Por ejemplo <form action="<?=$selected ?>"> y adentro mismo del form preguntarias por ejemplo... si selected1 esta seleccionado, entonces $selected = selected1.php-
Nunca hice algo asi, pero se me ocurre que por ahi pueda llegar a funcionar.

Y sino otra que se me ocurre es que cuando le das click al boton submit del form te envie a una pagina, la cual se va a encargar de preguntar... si un selected esta seleccionado, entonces lo redirije a una pagina, si otro select esta seleccionado entonces lo redirije a otra pagina.

Espero haberte ayudado, comenta como te fue
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de facundo

VALIDAR OPCION DE SELECT SI ES UNA OPCION QUE ABRA VENTANA Y ENVIE CORREO

Publicado por facundo (185 intervenciones) el 26/08/2017 17:45:12
Loco para que posteas si despues desapareces !
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar