Jump to content

POST does not work


phpllama

Recommended Posts

cash.php

<?php
$file = file('./file.txt');
$line = $file[array_rand ($file)];
$split = explode(",", $line);
$name = $split[0];
$number = $split[1];
if($_POST['numbers'] == $number){
    echo 'True';
} else {
    echo 'False';
}
?>
<form action="cash.php" method="post">
<?php echo "$name: "; ?><input name="numbers" type="text" /><input 

type="submit" />
</form>

 

file.txt

banana,1
orange,2
grape,3
lemon,4

 

The PHP reads the text file, chooses a random line, splits it up by comma into $name and $number. The form basically checks $number is correct. But it does not work correctly and comes up false.

Link to comment
https://forums.phpfreaks.com/topic/167360-post-does-not-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.