douju4594 2013-06-30 08:44 采纳率: 100%
浏览 73
已采纳

如何使用https在localhost上安全地从客户端向服务器发送密码

I looked for hours and I couldn't find a solution to my problem.

I'm currently testing a website on my laptop(local host). My site has a server side(php) and a client side.

I'm looking for away to send password using HTTPS, without specifying the absolute path. (My php and html are in the same directory)

My code looks like that:

      <!-- Submit data to server-side -->
      <form name="input" action="databasebuilder.php" method="post">
          <ul>
             <li>User name: <input type="text" name="user"> </li>
             <li>Password: <input type="text" name="password"> </li>
             <li>First name: <input type="text" name="name"> </li>
             <li>Last name: <input type="text" name="last"> </li>
             <li>Email: <input type="text" name="email"> </li>
         </ul>
             <input type="submit" value="Submit">
     </form>
  • 写回答

1条回答 默认 最新

  • duano3557 2013-06-30 08:47
    关注

    Either choose an absolute path or make sure that the page will be loaded using HTTPS. If the user types

    http://localhost/...
    

    in browser, your web application should redirect to:

    https://localhost
    

    You can ensure this for example using PHP or apache's mod_rewrite


    You can create the absolute path dynamically using PHP. Have a look at this example:

    $path  = 'https://';
    $path .= $_SERVER['HTTP_HOST'] . '/';
    $path .= 'path/to/your/app/action.php';
    echo '<form action="' . $path . '"....'; 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 socket通信实现多人聊天室疑惑
  • ¥15 DEV-C++编译缺失
  • ¥33 找熟练码农写段Pyhthon程序
  • ¥100 怎么让数据库字段自动更新
  • ¥15 antv g6 力导向图布局
  • ¥15 quartz框架,No record found for selection of Trigger with key
  • ¥15 锅炉建模+优化算法,遗传算法优化锅炉燃烧模型,ls-svm会搞,后面的智能算法不会
  • ¥20 MATLAB多目标优化问题求解
  • ¥15 windows2003服务器按你VPN教程设置后,本地win10如何连接?
  • ¥15 求一阶微分方程的幂级数