简体   繁体   中英

How to send data to php file other that the action=“ ” ?

I am doing a simple login check and was wondering how to send data to a PHP file other than what is specified in the action tag.

Like in this code I want the $cuslog=$_POST['cuslog']; to go to other PHP file but the page to go to the HTML file specified in the action tag ( e.action='WEBSITE/gallery.html )?

The idea is once the customer name data is checked (if it exists) then the page goes to gallery HTML and the customer id input is sent to another php file for knowing who is using the page currently.

My knowledge is limited to PHP, javascript, CSS, and HTML at the moment.

HTML named 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 named login.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>";
        }   
   }

?>

You can trigger inline img tag to pass Anonymous data.

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

security : Additionally some hash to validate will do the job

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM