通过php运行错误500

时间:2016-11-04 19:09:49

标签: php html server

我正在尝试以特定的方式将数据发送到我的根服务器
所以我做了一个表格:

    <form action="upload.php" id="s2" style="display: block;" method="post" enctype="multipart/form-data">

    <p>
    <input type="file" name="fileToUpload" id="fileToUpload"></p>
    <p><input style="margin:0px" onchange="document.getElementById('adm11').disabled = !this.checked;document.getElementById('adm12').disabled = !this.checked;" class="w3-check" type="checkbox" name="option1">
    <label class="w3-validate">Admin</label><input id="adm11" style="margin:0 0 0 20px;" class="w3-check" type="checkbox" name="option2" disabled="">
    <label class="w3-validate">OverWrite</label></p>
    <p>
    <button class="w3-btn w3-blue">Submit</button><input id="adm12" class="w3-input" name="pass1" type="password" style="display:inline-block;width:60%;margin-left:15px;" disabled=""></p>
    </form>

使用管理员按钮将密码和特定复选框发送到 PHP 服务器
我的问题是我找不到比较密码的方法 我每次尝试都会遇到此错误

example.com目前无法处理此请求。 HTTP ERROR 500

我是PHP服务器的初学者 我没有 SQL服务器,所以我通过make文件获取并通过 .htaccess

将其设为私有

这是PHP代码的最后一次测试:

$myfile = fopen("pass3.ini", "r") or die("Unable to open file!");
    $pass2 = fread($myfile,filesize("pass3.ini"));
    fclose($myfile);
    echo $pass2
    if ($pass2 = $_POST["pass1"]) {echo "yes"};

有谁有任何想法解决这个问题?

3 个答案:

答案 0 :(得分:1)

除了你错过了echo $pass2中的结束分号外,还有一些错误,你在这里做了一个单一的等号(一件事):

if ($pass2 = $_POST["pass1"])

而不是使用两个进行比较:

if ($pass2 == $_POST["pass1"])

这里的分号也是错位的:

if ($pass2 = $_POST["pass1"]) {echo "yes"};
                                          ^ right there

它应该读作

if ($pass2 == $_POST["pass1"]) { echo "yes"; }

参考文献:

使用错误报告,会抛出一个解析错误:

但是,不会抛出关于当前任务的错误,因为(信不信由你)是一个有效的陈述。

同时检查您尝试阅读的文件的正确权限,以及该文件的路径是否正确。

答案 1 :(得分:0)

;

之后你没有echo $pass2

答案 2 :(得分:0)

在以下行中替换HTML:

<button class="w3-btn w3-blue">Submit</button><input id="adm12" class="w3-input" name="pass1" type="password" style="display:inline-block;width:60%;margin-left:15px;" disabled=""></p>
    </form>

使用:

<input id="adm12" class="w3-input" name="pass1" type="password" style="display:inline-block;width:60%;margin-left:15px;" value="something" disabled/>
<input type="submit" class="w3-btn w3-blue" value="Submit" />
</p>
</form>

你需要在id =&#34; adm12&#34;中给出一些价值。这样你以后可以比较:)我做了#34;某事&#34;举个例子。

无论如何还要更新你的php文件:

$myfile = fopen("pass3.ini", "r") or die("Unable to open file!");
    $pass2 = fread($myfile,filesize("pass3.ini"));
    fclose($myfile);
    echo $pass2;
    echo $_POST["pass1"]; //it will paste "something"
    if ($pass2 === $_POST["pass1"]) {echo "yes"};//idk whats in your $pass2 but if its something same you are sending from html then it will print "yes"