2012-11-01 22 views
1

我有2個表格需要提交我似乎是有限的,因爲它是由mikrotik熱點的2個表格。 在mikrotic路由器的login.html的是多表單提交1提交JavaScript半工作

<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://domain.name/login.php" 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> 

所以當時我的login.php是這個

<?php 
    $mac=$_POST['mac']; 
    $ip=$_POST['ip']; 
    $username=$_POST['username']; 
    $linklogin=$_POST['link-login']; 
    $linkorig=$_POST['link-orig']; 
    $error=$_POST['error']; 
    $chapid=$_POST['chap-id']; 
    $chapchallenge=$_POST['chap-challenge']; 
    $linkloginonly=$_POST['link-login-only']; 
    $linkorigesc=$_POST['link-orig-esc']; 
    $macesc=$_POST['mac-esc']; 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html> 
<head> 
<title>mikrotik hotspot > login</title> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<meta http-equiv="pragma" content="no-cache" /> 
<meta http-equiv="expires" content="-1" /> 
<style type="text/css"> 
body {color: #737373; font-size: 10px; font-family: verdana;} 

textarea,input,select { 
background-color: #FDFBFB; 
border: 1px solid #BBBBBB; 
padding: 2px; 
margin: 1px; 
font-size: 14px; 
color: #808080; 
} 
a, a:link, a:visited, a:active { color: #AAAAAA; text-decoration: none; font-size: 
10px; } 
a:hover { border-bottom: 1px dotted #c1c1c1; color: #AAAAAA; } 
img {border: none;} 
td { font-size: 14px; color: #7A7A7A; } 
</style> 
<script language="JavaScript"> 
    function fnSubmit(){ 
    var form1Content = document.getElementById("form1").innerHTML; 
    var form2Content = document.getElementById("form2").innerHTML; 
var form3Content = document.getElementById("form3").innerHTML; 
    document.getElementById("toSubmit").innerHTML=form1Content+form2Content; 
      document.forms.toSubmit.submit(); 
    } 
    </script> 
</head> 

<body> 
<!-- $(if chap-id) --> 

    <form name="sendin" action="<?php echo $linkloginonly; ?>" method="post"   id="form1"> 
    <input type="hidden" name="username" /> 
    <input type="hidden" name="password" /> 
    <input type="hidden" name="dst" value="<?php echo $linkorig; ?>" /> 
    <input type="hidden" name="popup" value="true" /> 
</form> 

<script type="text/javascript" src="./md5.js"></script> 
<script type="text/javascript"> 
<!-- 
    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; 
    } 
//--> 
</script> 
    <!-- $(endif) --> 
    <div align="center"> 
    <a href="<?php echo $linkloginonly; ?>?target=lv&dst=<?php echo $linkorigesc; ?>">Hotspot</a> 
</div> 
    <table width="100%" style="margin-top: 10%;"> 
<tr> 
<td align="center" valign="middle"> 
Please log on to use the mikrotik hotspot service 
    </div><br /> 
    <table width="240" height="240" style="border: 1px solid #cccccc; padding: 0px;"  cellpadding="0" cellspacing="0"> 
<tr> 
<td align="center" valign="bottom" height="175" colspan="2"> 
    <!-- removed $(if chap-id) $(endif) around OnSubmit --> 
    <form method="POST" action="signin.php" id="form2"> 
    First Name<p><input type="text" name="firstname" size="30"></p> 
    Surname<p><input type="text" name="lastname" size="30"></p> 
Email address <font color="red"> (required)</font><p><input type="text" name="email" size="30"></p> 
    <input type="submit" value="submit" onclick="javascript:fnSubmit();"/> 
</form> 
    <form name="login" id="form3 action="<?php echo $linkloginonly; ?>" method="post" onSubmit="return doLogin()" > 
     <input type="hidden" name="dst" value="<?php echo $linkorig; ?>" /> 
     <input type="hidden" name="popup" value="true" /> 
     <table width="100" style="background-color: #ffffff"> 
      <tr><td align="right"></td> 
      <td><input type="hidden" style="width: 80px" name="username" type="text" value="user2"/></td> 
      </tr> 
      <tr><td align="right"></td> 
      <td><input type="hidden" style="width: 80px" name="password" type="password" value="user2"/></td> 
      </tr> 
      <tr><td> </td> 
      <td><td></td></td></td> 
      </tr> 
     </table> 
    </form> 

    </td> 
    </tr> 
</table> 

<!-- $(if error) --> 
<br /><div style="color: #FF8080; font-size: 9px"><?php echo $error; ?></div> 
<!-- $(endif) --> 

</td> 
</tr> 
</table> 

<script type="text/javascript"> 
<!-- 
    document.login.username.focus(); 
//--> 

</script> 

</body> 
</html> 

,你可以看到我嘗試自動提交的用戶名和密碼 這樣只有用戶輸入自己的電子郵件地址,要做到這一點,我想一個數據庫 存儲的電子郵件中 與signin.php 這是本

<?php 
ini_set('display_errors', 'On'); 
// Receiving variables 
@$pfw_ip= $_SERVER['REMOTE_ADDR']; 
@$firstname = addslashes($_POST['firstname']); 
@$lastname = addslashes($_POST['lastname']); 
@$email = addslashes($_POST['email']); 
@$date = addslashes($_POST['date']); 


// Validation 
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email)) 
{ 
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>"); 
} 

if (strlen($email) == 0) 
{ 
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>"); 
} 


      /* adding user information to the userinfo table */ 
         @$pfw_strQuery = "INSERT INTO userinfo (firstname, lastname, email, creationdate) values ". 
       "('$firstname', '$lastname', '$email', NOW())"; 


@$pfw_host = "localhost"; 
@$pfw_user = "dbusername"; 
@$pfw_pw = "dbpassword"; 
@$pfw_db = "database"; 

$pfw_link = mysql_connect($pfw_host, $pfw_user, $pfw_pw); 
if (!$pfw_link) { 
die('Could not connect: ' . mysql_error()); 
} 
$pfw_db_selected = mysql_select_db($pfw_db, $pfw_link); 
if (!$pfw_db_selected) { 
die ('Can not use $pfw_db : ' . mysql_error()); 
} 

//insert new record 
$pfw_result = mysql_query($pfw_strQuery); 
if (!$pfw_result) { 
die('Invalid query: ' . mysql_error()); 
} 
mysql_close($pfw_link); 

header('Location: http://www.google.co.uk'); 

?> 

發生的事情是電子郵件地址存儲在MySQL表 但存儲的用戶名和密碼的形式,不通過,我在登錄頁面

我失去了什麼結束了?

感謝所有

+2

哇,這看起來像一個大混亂...你可以嘗試減少你的問題,只有基本部分? – elclanrs

+0

實際上,我認爲發生的事情是第一個表單被提交將電子郵件插入到數據庫中,但後來我認爲signin.php需要在運行時自動提交第二個表單,那麼它將起作用 – djbridger

+0

任何人都有想法? – djbridger

回答

0

好答案是消除所有的login.php的JavaScript和使用一個簡單的形式與signin.php通過用戶名和密碼使用PAP登錄。所有工作和快樂的快樂兔子