Permisi gann ane mau numpang nanya..
kronologisnya gini ..
ane tuh lagi ngebuat loginpage untuk hotspotmikrotik berbasis web external,difungsi kan buat input data user yang masuk..
ada 3 kolom yang ane buat.
1.username ->dapetnya dari mikrotik
2.password->dapetnya dari mikrotik
3.email->isi sendiri dan saat login yang ane mau email ini keinput kedlam databese mysqli.
jadi alurnya gini..
User konek kehotspot->buka browser nanti browser akan diarahkan keurl login hotspot ->dia masukin username dan password yang ane berikan ,dan dia harus mengisi email dia ->saat dia klik get connected dia akan otomatis redirect ke halaaman url yang ane tuju google..
otomatis dia dh masuk dong,,nah ane mau data yang td dia input diloginhotspot juga masuk semua kedtaabese mysqli..
ane bingung dengan codingan ane ko gak masuk2 inputannya kedatabese mysqli
ini codingan php nya
Spoiler for login.php :
Code:
<?php
include"koneksi.php";
$mac=$_POST['mac'];
$ip=$_POST['ip'];
$username=$_POST['username'];
$email=$_POST['email'];
$linklogin=$_POST['link-login'];
$linkorig=$_POST['link-orig'];
$chapid=$_POST['chap-id'];
$chapchallenge=$_POST['chap-challenge'];
$linkloginonly=$_POST['link-login-only'];
$linkorigesc=$_POST['link-orig-esc'];
$macesc=$_POST['mac-esc'];
echo $linkloginonly;
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "varchar":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "login")) {
$insertSQL = sprintf("INSERT INTO usrnovotel (username, password, email) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['user'], "varchar"),
GetSQLValueString($_POST['password'], "varchar"),
GetSQLValueString($_POST['email'], "varchar"));
$Result1 = mysqli_query($insertSQL, $koneksi) or die(mysqli_error());
$insertGoTo = "list-data.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<title>Hotspot Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Login ke Hotspot Mikrotik." />
<meta name="author" content="kurei" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
[removed][removed]
[removed][removed]
[removed]
window.addEvent('domready', function(){check = new FormCheck('third', {
display : {
fadeDuration : 500,
errorsLocation : 1,
indicateErrors : 1,
showErrors : 1
}
})});
[removed]
[removed]
function validateEmail(email) {
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return re.test(email);
}
$( document ).ready(function() {
$("#btn-login").click(function(e){
e.preventDefault();
var username = $("#username").val();
var password = $("input[id='password']").val();
var email = $("#email").val();
if(username == undefined || username == ""){
alert("Please Fill Username");
}else if(password == undefined || password == ""){
alert("Please Fill Password");
} else if(email == undefined || email == ""){
alert("Please Fill email");
} else if( validateEmail(email) == false ){
alert("Wrong email format");
}else {
var params = "email="+email;
$.ajax({
type : 'POST',
dataType: "json",
url: "mail.php",
data: params,
success: function(data){
if(data.status){
alert(data.msg);
}else{
doLogin();
//document.login.submit();
}
},
error: function( xhr, tStatus, err ) {
console.log("e :" + tStatus + " " + err);
}
});
}
return false;
});
});
[removed]
</head>
<body>
<div id="wrap">
<div id="inputan">
<form name="login" class="niceform" id="third" action="<?php echo $editFormAction; ?>" method="post" >
<input type="hidden" name="dst" value="http://www.novotel-banjarmasin-airport.com" />
<input type="hidden" name="popup" value="true"/>
<label for="name">Username</label>
<input id="name" name="username" type="text" class="validate['required','length[3,-1]']" size="20" value="<?php echo $username; ?>"/><br />
<label for="name">Password</label>
<input id="password" name="password" type="password" class="validate['required','length[3,-1]']" size="20" />
<label for="password">Email</label>
<input name="email" id="email" type="text" class="validate['required','length[3,-1]']" size="20"/>
<br /><br />
<td><input type="submit" name="btnLogin" value="Get Connected" id="btn-login"/></td>
</form>
</div>
<!-- $(if chap-id) -->
<form name="sendin" action="<?php echo $linkloginonly,$insertGoTo; ?>" method="post">
<input type="hidden" name="username" value="username" />
<input type="hidden" name="password" value="username"/>
<input type="hidden" name="dst" value="<?php echo $linkorig; ?>" />
<input type="hidden" name="popup" value="true" />
</form>
[removed][removed]
[removed]
<!--
function doLogin() {
<?php if(strlen($chapid) < 1) echo "return true;\n"; ?>
document.sendin.username.value = document.login.username.value;
document.sendin.password.value = hexMD5('<?php echo $chapid; ?>' + document.login.password.value + '<?php echo $chapchallenge; ?>');
document.sendin.submit();
return false;
}
//-->
[removed]
<!-- $(endif) -->
<br /><div style="color: #FF8080; font-size: 9px"><?php echo $error; ?></div>
[removed]
<!--
document.login.username.focus();
//-->
[removed]
</body>
</html>
Makasih bnyakk gan sebelumnya hehe soale sambil proses belajar dan dh buntu ke gmna lagi wawasannya kurang nyari ggoole nyoba sanasini ttp gbisa