【问题标题】:ssl certificate causes one file not workingssl 证书导致一个文件不工作
【发布时间】:2018-07-30 05:32:29
【问题描述】:

最近我获得了 SSl 证书并安装了,后来似乎一切正常,但一个文件 (index1.php) 无法正常工作,并且该文件仅适用于 http 而不是 https 选项卡注册(#Signup)仅显示(#sigin)正在工作(在使用的情况下。)但在使用(http://..)时工作正常,我看不到任何错误。这是我的.php 文件:

<?php /* Main page with two forms: sign up and log in */
require 'db.php';
session_start();?>
<!DOCTYPE html><html><head>  <title>Sign-Up/Login Form</title>
<?php include 'css/css.html'; ?></head>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
if (isset($_POST['login'])) { //user logging in

    require 'login.php';

}

elseif (isset($_POST['register'])) { //user registering

    require 'register.php'; }}?>
<body>  <div class="form">

  <ul class="tab-group">
    <li class="tab"><a href="#signup">Sign Up</a></li>
    <li class="tab active"><a href="#login">Log In</a></li>
  </ul>

  <div class="tab-content">

     <div id="login">   
      <h1>Welcome Back!</h1>

      <form action="index1.php" method="post" autocomplete="off">

        <div class="field-wrap">
        <label>
          Email Address<span class="req">*</span>
        </label>
        <input type="email" required autocomplete="off" name="email"/>
      </div>

      <div class="field-wrap">
        <label>
          Password<span class="req">*</span>
        </label>
        <input type="password" required autocomplete="off" name="password"/>
      </div>

      <p class="forgot"><a href="forgot.php">Forgot Password?</a></p>

      <button class="button button-block" name="login" />Log In</button>

      </form>

    </div>

    <div id="signup">   
      <h1>Sign Up for Free</h1>

      <form action="index1.php" method="post" autocomplete="off">

      <div class="top-row">
        <div class="field-wrap">
          <label>
            First Name<span class="req">*</span>
          </label>
          <input type="text" required autocomplete="off" name='firstname' />
        </div>

        <div class="field-wrap">
          <label>
            Last Name<span class="req">*</span>
          </label>
          <input type="text"required autocomplete="off" name='lastname' />
        </div>
    </div>


    <div class="top-row">
        <div class="field-wrap">
          <label>
            City <span class="req">*</span>
          </label>
          <input type="text" required autocomplete="off" name='City' />
        </div>

        <div class="field-wrap">
          <label>
            Postal<span class="req">*</span>
          </label>
          <input type="text"required autocomplete="off" name='Postal' />
        </div>
    </div>


    <div class="top-row">
        <div class="field-wrap">
          <label>
            Street<span class="req">*</span>
          </label>
          <input type="text" required autocomplete="off" name='Street' />
        </div>

        <div class="field-wrap">
          <label>
            buildingNo<span class="req">*</span>
          </label>
          <input type="text"required autocomplete="off" name='buildingNo' />
        </div>
    </div>


    <div class="top-row">
        <div class="field-wrap">
          <label>
            phone<span class="req">*</span>
          </label>
          <input type="text" required autocomplete="off" name='phone' />
        </div>

        <div class="field-wrap">
          <label>
            Room (if any)
          </label>
          <input type="text"notrequired autocomplete="off" name='noteadress' />
        </div>
    </div>

      <div class="field-wrap">
        <label>
          Email Address<span class="req">*</span>
        </label>
        <input type="email"required autocomplete="off" name='email' />
      </div>

      <div class="field-wrap">
        <label>
          Set A Password<span class="req">*</span>
        </label>
        <input type="password"required autocomplete="off" name='password'/>

      </div>
          <div class="field-wrap">
       <h3 style="color:green"> By clicking Register, you agree to our Terms and that you have read our <span><a  href="../../../../forms/terms-and-conditions/index.html">Data Use Policy</a></span>, including our Cookie Use</h3>
      </div>

      <button type="submit" class="button button-block" name="register" />Register</button>

      </form>

    </div>  

  </div><!-- tab-content -->

</div> <!-- /form -->
  <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>

    <script src="js/index.js"></script>

</body>
</html>

【问题讨论】:

  • 一些合理的代码缩进是个好主意。它可以帮助我们阅读代码,更重要的是,它将帮助 您调试代码 Take a quick look at a coding standard 为您自己谋福利。您可能会被要求在几周/几个月内修改此代码,最后您会感谢我的。
  • &lt;script src='http://cdnjs... - 如果您在 https 下,所有资产(js、css、图像等)也需要在 https 下调用,否则某些浏览器可能会阻止这些文件“不安全” "
  • "http://cdnjs.cloudflare.com..." 更改为"//cdnjs.cloudflare.com..." 将适用于这两种情况。
  • 正如@Syscall 和 Magnus Eriksson 建议的那样,您的问题可能是由于内容混合造成的。当页面是来自 https 的服务器但来自 http 的静态文件(jquery javascript 文件)时,它们不会被加载,并且由于缺少 jquery,您的页面锚点不起作用。 Here 是一篇关于混合内容的好文章。

标签: php mysql http ssl https


【解决方案1】:

可能会尝试改变:

<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>

收件人:

<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>

如果只是将 http 更改为 https 不起作用,则需要找到链接的 https 版本。

【讨论】:

  • 问题解决了,把脚本从http改成https
  • 现在上面的表格正在向Mysql输入注册信息。如果我想使用选项从下拉列表中选择城市和街道并将该选项弹出到 Mysql 中的表中,我该怎么做?
  • 我不太明白这个问题。最好将此问题标记为已回答并针对您的问题打开另一个问题。
猜你喜欢
  • 2013-04-24
  • 2018-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-28
  • 1970-01-01
  • 1970-01-01
  • 2021-12-20
相关资源
最近更新 更多