我正试图做一个mikrotik热点的singup表单,这个设备不允许在里面使用PHP,而且我需要将变量从设备传递到一个外部php页面挽救该负荷消费数据,并实现在热点的审判......两个HTML和PHP之间的交换变量
这个设备里面它主持了一个HTML页面下面的代码
<html>
<head><title>...</title></head>
<body>
$(if chap-id)
<noscript>
<center><b>JavaScript required. Enable JavaScript to continue.</b></center>
</noscript>
$(endif)
<center>If you are not redirected in a few seconds, click 'continue' below<br>
<form name="redirect" action="http://10.2.3.100/cadastro.html?mac=$(mac)" method="post">
<input type="hidden" name="mac" value="$(mac)">
<input type="hidden" name="ip" value="$(ip)">
<input type="hidden" name="username" value="$(username)">
<input type="hidden" name="link-login" value="$(link-login)">
<input type="hidden" name="link-orig" value="$(link-orig)">
<input type="hidden" name="error" value="$(error)">
<input type="hidden" name="chap-id" value="$(chap-id)">
<input type="hidden" name="chap-challenge" value="$(chap-challenge)">
<input type="hidden" name="link-login-only" value="$(link-login-only)">
<input type="hidden" name="link-orig-esc" value="$(link-orig-esc)">
<input type="hidden" name="mac-esc" value="$(mac-esc)">
<input type="submit" value="continue">
</form>
<script language="JavaScript">
<!--
document.redirect.submit();
//-->
</script></center>
</body>
</html>
我已经学会了在谷歌搜索,我可以送变量到另一个页面,通过在URL的末尾插入它,所以好的,我会发送变量$ MAC,我需要开始试用。
接收它的页面是一个HTML格式的页面,我无法接收这个页面中的变量,我需要接收这个变量发送到另一个页面,在PHP中最后一个将保存表单MySQL和后向Mikrotik发送与客户端的MAC链接,以允许它在互联网上浏览。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>CADASTRO DE CLIENTES COM BANCO DE DADOS E PHP</title>
<style type="text/css">
</head>
<body>
<p id="demo"></p>
<script type"text/javascript">
var qs = new QueryString();
var v1 = qs.get("mac");
document.getElementById("demo").innerHTML = v1;
</script>
<form id="cadastro" name="cadastro" method="post" action="cadastro.php" onsubmit="return validaCampo(); return false;">
<table width="625" border="0">
<tr>
<td width="69">Nome:</td>
<td width="546"><input name="nome" type="text" id="nome" value="$(mac)" size="70" maxlength="60" />
<span class="style1">*</span></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="email" type="text" id="email" size="70" maxlength="60" />
<span class="style1">*</span></td>
</tr>
<tr>
<td colspan="2"><p>
<input name="cadastrar" type="submit" id="cadastrar" value="Concluir meu Cadastro!" />
<br />
<input name="limpar" type="reset" id="limpar" value="Limpar Campos preenchidos!" />
<br />
<span class="style1">* Campos com * são obrigatórios! </span></p>
<p> </p></td>
</tr>
</table>
</form>
</body>
</html>
现在PHP页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
// RECEBENDO OS DADOS DO PC DO USUARIO
$mac=$_POST['mac'];
// RECEBENDO OS DADOS PREENCHIDOS DO FORMULÁRIO !
$nome = $_POST ["nome"]; //atribuição do campo "nome" vindo do formulário para variavel
$email = $_POST ["email"]; //atribuição do campo "email" vindo do formulário para variavel
//Gravando no banco de dados !
//conectando com o localhost - mysql
$conexao = mysql_connect("localhost","root","senha");
if (!$conexao)
die ("Erro de conexão com localhost, o seguinte erro ocorreu -> ".mysql_error());
//conectando com a tabela do banco de dados
$banco = mysql_select_db("cadhotspot",$conexao);
if (!$banco)
die ("Erro de conexão com banco de dados, o seguinte erro ocorreu -> ".mysql_error());
$query = "INSERT INTO `clientes` (`nome` , `email` )
VALUES ('$nome', '$email', '$sexo' '')";
mysql_query($query,$conexao);
echo "Seu cadastro foi realizado com sucesso!<br>Agradecemos a atenção.";
?>
Mac: <?php echo $mac ?><br>
<meta http-equiv="refresh" content="60; url=<?php echo $linkloginonly; ?>?dst=<?php echo $linkorigesc; ?>&username=T-<?php echo $mac; ?>">
</body>
</html>
的想法是,从客户设备从的MikroTik与形式为客户singup接收MAC在其主持的HTML页面,该载荷经过HTML页面当客户点击发送过来将写信给mysql和发回的链接下方的MikroTik
<meta http-equiv="refresh" content="60; url=http://10.5.50.1?&username=T-<?php echo $mac; ?>">
我的整个问题交换HTML之间的变量HTML和PHP后页秒。
php会话可能吗? – 2014-09-24 14:40:17
你可以使用JavaScript例如?然后你可以阅读你的网址中的参数.. – Matheno 2014-09-24 14:41:03
这看起来恐怖不安全。你确定**你的用户参数是[妥善转义](http://bobby-tables.com/php)? '$ _POST'数据**从不**直接进入查询。 'mysql_query'是一个过时的界面,不应该在新的应用程序中使用,并且会在将来的PHP版本中删除。像[PDO这样的现代化替代品并不难学](http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/)。如果您是PHP的新手,像[PHP The Right Way](http://www.phptherightway.com/)这样的指南可以帮助解释最佳实践。 – tadman 2014-09-24 14:55:52