Reading value from text file into Php Variable

Associate
Joined
6 Mar 2009
Posts
495
Hi Guys

I have a testing website that checks tests done on products to see if they have passed or failed. So for example the user may type into the table and it will check if it has passed/failed. For example to pass the value may have to be in the range of 5-20. At the minute i have it checking the inputted value with if statements and < > signs to check if the value is in the range of 5-20.

Now and again the range/spec may change and i would like a way of having the range stored in a text file or excel file and for the program to read the value from there so it could be easily changed if need be.

I can read values from a text file and print them but not sure how i could save it in a php variable and then use that value in my testing check.

For example this is how i check if the value is in a certain range to pass or fail

Code:
if(($_POST[field1] >0) && ($_POST[field2]<=20) && ($_POST[field3] >=80) && ($_POST[field4] <=100))

Could anyone help me on this please?

Thanks
 
Ok i created this piece of code:

PHP:
$file = "testFile.txt";
	$lines = file( $file ); 
			
if(($_POST[field1] > $lines[0]) && ($_POST['field2'] <= $lines[1] ) && ($_POST['field3'] >= $lines[2] ) && ($_POST['field4'] <=$lines[3]))

I have a text file with the numbers 20,30,70,80 in it. This code will pass the product if the values are between 20-30 in one field and 70-80 in the second field.

This will only pass the test if i input 30 in the first field and 80 in the second. It wouldnt pass anything that is inside the range.

Can anyone help me please??
 
Back
Top Bottom