2017-08-11 103 views
0

我做一个简单的登录检查和不知道如何将数据发送到比在动作标签中指定其他的PHP文件。如何发送数据到php文件其他的动作=“”?

如在此代码,我想$ cuslog = $ _ POST [ 'cuslog'];去其他PHP文件,但页面去的动作标签(e.action ='网站/ gallery.html)指定的HTML文件?

的想法是一旦客户名称数据被选中(如果存在的话),那么页转到图库HTML和客户ID输入发送到另一个PHP文件知道谁正在使用的页面。

我的知识仅限于PHP,JavaScript中,CSS和HTML的时刻。

HTML的login.html

<html> 
<head> 
<title>about</title> 
<link rel="stylesheet" type="text/css" href="navbar.css"> 
<body> 
    <form method="post" action="../login.php" class="form" >    
    <div class="login">Custormer ID<br><input type="text" name="cuslog">  
    <input type="submit" value="Login"></div> 
    </form>    
</body> 
</html> 

PHP命名的log​​in.php

<?php 
    $cuslog=$_POST['cuslog']; 
?> 

<html> 
<head><title>Login</title> 
<body> 
<form id="to-login" method="POST"> 
    <input type="hidden" name="hidden_username" value="<?php echo $cuslog; ?>" /> 
</form> 
</body> 
</html> 

<?php 
if (!empty($_POST["cuslog"])){ 
     $cuslog=$_POST['cuslog']; 
     $search=mysql_query("select CustomerID from orders where 
           CustomerID=$cuslog"); 
     $rows=mysql_num_rows($search); 
     //$data=mysql_fetch_row($search); 
     if($rows !== 0){ 
      echo" <script type=\"text/javascript\"> 
        var e = document.getElementById('to-login'); 
        e.action='WEBSITE/gallery.html'; 
        e.submit(); 
        </script>"; 
     } 
     else { 
      echo "[Login]Account Doesn't Exist<br>"; 
     } 
    } 

?> 
+0

你为什么不使用Cookie来的工作吗? –

+0

您可能需要使用Ajax将用户名发送到php文件 –

+1

您应该通过会话管理用户并将用户重定向到相册中 –

回答

0

命名可以触发在线img标签通过匿名数据。

<img src="customer_idtrack.php?customer_id=<?php echo $customerid; ?>" alt="InlineImgtag to pass customer id" height="0" width="0"/> 

安全:此外,一些哈希验证会做

相关问题