包含文件时发生冲突

时间:2015-03-21 15:45:56

标签: javascript php jquery html css

我正在尝试包含一个生成2个需要添加的随机数或我们称之为验证码的文件。我有两个登录:一个需要员工ID,生日和验证码答案(我称之为轻松登录)。而另一个需要你的名字,姓氏,生日和验证码(我称之为标准登录)。所以我有两个单选按钮供用户选择是轻松登录还是标准登录。所以当你选择登录时我遇到了这个问题然后你需要回答验证码(验证码发送会话以获得答案)所以发生的事情是正确的,登录中的验证码总是被验证码覆盖。标准登录。我认为我会做的是设置一个条件,如果选择单选按钮(轻松登录),那么它将被包括在内。但我不知道该怎么做。

以下是验证码: 的 captcha.php

<?php
session_start();

$n1=rand(1,6); //Generate First number between 1 and 6  
$n2=rand(5,9); //Generate Second number between 5 and 9  
$answer=$n1+$n2;  

$math = "What is ".$n1." + ".$n2." ? ";  
$_SESSION['vercode'] = $answer;

print $math;

?>

然后这是我的界面的代码:

的index.php

<SCRIPT TYPE="text/javascript">

function toggleTables(which)
{

if(which == "0") {

    document.getElementById('standard').style.display = "table";
    document.getElementById('customize').style.display = "none";
    }
    if(which == "1") {

    document.getElementById('customize').style.display = "table";
    document.getElementById('standard').style.display = "none";
    }
}

</SCRIPT>

</head>
<body style="background: url(../images/background.jpg) no-repeat center center fixed; 
          -webkit-background-size: cover;
          -moz-background-size: cover;
          -o-background-size: cover;
          background-size: cover;" >
<a href="http://i-refer.elitebpocareers.com" align="center"><?php include('../include/logoheader.php'); ?></a>




<div class="row">
<div class="twelve columns">
    <hr />
</div>
</div>

<div class="row">
<div class="two columns">

</div>

<div class="eight columns">
    <div class="content">

        <?php include('../include/retain-empid.php'); ?>

        <br>

        <input name="radio" type="radio" id="customize_1" onClick="toggleTables('0')" value="radio" /><font color="white">Standard Login</font>
        <input name="radio" type="radio" id="customize_0" onClick="toggleTables('1')" value="radio" checked="checked"/><font color="white">Easy Login</font>

        <form name="loginform" action="login_exec.php" method="post" >

        <center><?php include('../function/login_errmsg.php'); ?></center>


        <table width="100%" class="imagetable" cellpadding="0" cellspacing="0" id="customize">
                <tr>
                <th colspan="4">
                    Easy Log-in For Registered Convergys Employees
                </th>
            </tr>

                <tr>
                    <td align="right">
                        <label>Employee Number</label>
                    </td>

                    <td>
                    <input type="text" placeholder="Employee Number" name="txt_EmpID" autoComplete="off" value=<?php echo $value; ?> >
                    </td>

                <td align="right">
                        <label>Birthday</label>
                    </td>


                <td>
                    <input type="date" class="" placeholder="Birthday" id="txt_BDate" name="txt_BDate" autoComplete="off" maxlength = "10" 
                    style ="width:170px;"/>
                </td>

                </tr>

            <tr>
                <td align="right">
                    <label class="labels" align="center">
                        <strong>
                        </strong>   
                    </label>
                    </td>
                <td>
                <?php
                include ('../include/mathcaptcha.php');
                ?>
                </td>
                <td>
                    <input name="captcha" type="text" placeholder="Answer to math question">
                </td>

                <td>
                </td>
                <td>
                    <input type="submit" id="submit" name="btn_refer" class="btn" value="Submit" 
                    style=" width: 170px; height: 30px; font-size: 11pt; ">
                    </td>
                </tr>

        </table>
        </form>

        <form action="otherlogin_exec.php" method="post"> 
        <table width="100%" class="imagetable" cellpadding="0" cellspacing="0" id="standard" style="display: none">

                <tr>
                    <th colspan="4">
                        Standard Log-in For All Registered Users
                    </th>
                </tr>

            <tr>
                <td align = "right">
                    <label>First name:</label>
                </td>

                <td>
                    <input type="text" placeholder="First Name" name="txtFirstName" autoComplete="off" >
                </td>

                <td>
                    <label>Last name:</label>
                </td>

                <td>
                    <input type="text" placeholder="Last Name" name="txtLastName" autoComplete="off" >
                </td>
                </tr>

            <tr>
                <td>
                    <label>Birthday:</label>
                </td>

                    <td>
                    <input type="date" class="" placeholder="Birthday" id="txt_BDate" 
                    name="txtPassword" autoComplete="off" maxlength = "10" style = "width:170px;"/>
                </td>

                <td>
                    <label class="labels" align="center">
                        <strong>

                        </strong>   
                    </label>

                </td>
                <td>
                <?php
                include ('../include/mathcaptcha.php');
                ?>
                </td>                   
                <td>
                    <input name="captcha" type="text" placeholder="Answer to math question">
                </td>
            </tr>

            <tr>
                <td>
                </td>

                <td>
                </td>

                <td>
                </td>

                <td>
                    <input type="submit" id="submit" name="btn_refer" class="btn" value="Submit" 
                    style=" width: 100%; height: 30px; font-size: 11pt; ">
                </td>
            </tr>
        </table>
        </form>
    </div>
    </div>

1 个答案:

答案 0 :(得分:0)

制作文件的第一行

<?php include_once ('../include/mathcaptcha.php'); ?&GT;

然后从

更改行
      <td>
            <?php
            include ('../include/mathcaptcha.php');
            ?>
            </td>       

      <td><?php echo $math;?></td>

并从captcha文件中取出打印件。 PHP不会影响页面的设计,只会输出应根据需要更改的输出数据。