aidn aidn - 1 year ago 57
HTML Question

Run error 500 by php

I'm trying to specific way to send data to my root server

So I made a form:

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

<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>
<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>

with an admin button that will send a password and specific checkbox to PHP server

My Problem is I can not find a way to comparing the password

every time I try I got this error is currently unable to handle this request. HTTP ERROR 500

I'm Beginner in PHP servers.

I don't have SQL server, so I got way by make file and make it private by .htaccess

This is the Last test for the PHP code:

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

Has anyone any idea to solve this problem?

Answer Source

Apart from where you missed the closing semi-colon in echo $pass2, there are a few more errors, where you're doing an assignment here with a single equal sign (for one thing):

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

rather than doing a comparison using two:

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

The semi-colon in this is also misplaced:

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

where it should read as

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


Using error reporting, would have thrown you a parse error:

But, would not have thrown an error about the present assignment, since (believe it or not) is a valid statement.

Also check for proper permissions on the file you're trying to read from and that the path for it is correct.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download