PHP file not opening

I placed a file on my website server with HTML and PHP in it and named the file 'php1.php'. I tried running the file and all was fine. Later after some time abruptly I got a 500 ERROR and continued to get them despite my site being accessible. Then to test I copied this file with name changed to 'php1.html' and ran the file and the PHP code was being loaded a text. All other PHP files are running well. Other HTML files requiring PHP are kept seperately as two files and only this file has PHP coded with HTML in the same file.

I ran a phpinfo function and got this. http://analyzedstock.com/test/phpinfo.php . Is all fine with the installed PHP? What could be the problem with my file then? I have simple functions to output. The link to my PHP page is here: http://analyzedstock.com/test/PHP/php1.php

Also I would be very thankful if you find any errors in my code. I get ' Log in success. ' at the start of the form.

<?PHP

//form variables

$name=$_POST['username'];
$password=$_POST['password'];
$email=$_POST['email'];

//current

$minname=10;
$minpass=6;
$maxname=15;
$maxpass=10;

//functions

function username($username){
empty($username) || $username<$minname || $username>$maxname;
return username($username);
}

function password($password){
 empty($password) || $password<$minpass || $password>$maxpass;
return password($password);
}

//function email($email){
//    empty($email) || !isset("\@") || !isset(".com");
//}

if(username($username) && password($password)){
 echo"Log in Error!!";
 }else{
echo"Log in success.";
}

?>

<html>
<head>
<title>First try</title>
</head>
<body>

Log In
<form action="php1.php" method="POST">
Username: <input type="text" name="username" /><br />
Password: <input type="password" name="password" /><br />
<!--E-mail: <input type="text" name="email" /><br />-->
<input type="submit" value="Submit" />
</form>

</body>
</html>

Answers


Please add the following lines to your php file to see what for error you get:

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);
?>

Ok the following lines are incorrect:

function password($password){
 empty($password) || $password<$minpass || $password>$maxpass;
return password($password);
}

The conditions should between a if condition

Change to:

function username($username){
 if(empty($username) || $username<$minname || $username>$maxname)
    return $username;
}

function password($password){
 if(empty($password) || $password<$minpass || $password>$maxpass)
    return $password;
}

And also change PHP to lowercase (what already is said) ==> < ? php


Infinite recursion, undefined $minpass, expecting boolean but returning string/null/infinite, < without strlen:

function username($username){
    $minname = 8;
    if (empty($username) || $username<$minname || $username>$maxname)
       return username($username);
}

function password($password){
     $minpass = 8;
     if (empty($password) || $password < $minpass || $password > $maxpass) 
        return password($password);
}

"return myself, return myself again, return myself again,.. again.. again... 500 times..."

Better:

function username($username){
    if (empty($username) || strlen($username)<$minname || strlen($username)>$maxname) 
        return true;
    else return false;
}

function password($password){
     if (empty($password) || strlen($password)<$minpass || strlen($password)>$maxpass) 
        return true;
     else return false;
}

Also logical wrong:

if(username($username) && password($password)){

should be

if(username($username) || password($password)){

because you want: "if either one of those expressions fail, send error msg"


Need Your Help

Grabbing and sending elements from MongoDB in Node.js server response

javascript node.js mongodb mongoose synchronous

In my Express route, I am trying to return a list of elements that I am grabbing from MongoDB using Mongoose. I'm basically iterating through an array of items, and making MongoDB calls to get the

sqlite query not getting all records if 1 table has missing data

sql database sqlite

I've got a very complex database with a lot of tables in SQLite. I'm trying to design a query that will report out a lot of data from those tables and also report out those sheep who may not have a

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.