我正在尝试特定的方式发送数据到我的根服务器
所以我创建了一个表单:
<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>
带有一个admin按钮,它将发送一个密码和特定的复选框到PHP服务器
我的问题是我找不到比较密码的方法
每次我尝试,我得到这个错误
example.com目前无法处理此请求。HTTP错误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"};
谁有解决这个问题的办法? 除了您在echo $pass2
中错过了关闭分号之外,还有一些错误,您在这里使用单个等号(用于一件事)进行赋值:
if ($pass2 = $_POST["pass1"])
而不是使用two进行比较:
if ($pass2 == $_POST["pass1"])
这里的分号也放错了位置:
if ($pass2 = $_POST["pass1"]) {echo "yes"};
^ right there
应该读作
if ($pass2 == $_POST["pass1"]) { echo "yes"; }
引用:
- http://php.net/manual/en/language.operators.assignment.php
- http://php.net/manual/en/language.operators.comparison.php
使用错误报告,会抛出一个解析错误:
- http://php.net/manual/en/function.error-reporting.php
但是,不会抛出关于当前赋值的错误,因为(信不信由你)是一个有效的语句。
还要检查您试图读取的文件的权限是否正确,以及它的路径是否正确。
echo $pass2
之后没有;
替换以下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="adm12"中给出一些值,以便稍后进行比较:)我以"某事"为例。
无论如何也更新你的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"