'Trouble with $_POST [duplicate]
so I am trying to get this to post data to solutions.php in my files. but when i print_r($_POST); I dont get any values in my POST.
<form action="solutions.php" method='post'>
<?php
# starting array
$row1 = array ( " "," "," " ,"2","6"," " ,"7"," " ,"1");
$row2 = array ("6","8"," "," ","7"," "," ","9"," ");
$row3 = array ( "1","9"," " ," "," ","4" ,"5"," " ," ");
$row4 = array ( "8","2"," " ,"1"," "," " ," ","4" ," ");
$row5 = array ( " "," ","4" ,"6"," ","2" ,"9"," " ," ");
$row6 = array ( " ","5"," " ," "," ","3 " ," ","2" ,"8");
$row7 = array ( " "," ","9" ,"3"," "," " ," ","7" ,"4");
$row8 = array ( " ","4"," " ," ","5"," " ," ","3 " ,"6");
$row9 = array ( "7"," ","3" ," ","1","8" ," "," " ," ");
#correct answers
//$cor1 = array("4","3","5","2","6","9","7","8","1" );
#row 1
echo "<table>
<tr class='row'>";
for($i=0; $i<9; $i++){
echo" <td class='cellTop'><input type='text' maxlength='1' name='row'
value=$row1[$i]></td>
";}
echo "</tr>";
This is how i am trying to use it in the solutions page, at this point i am really not sure what i am doing wrong. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if($_POST['row']){
$row1 = $_POST['row'];
print_r($_POST);
echo count($_POST);
}else{
$row1=NULL;
echo "<p> why isnt this working? </p>";
}
These are the arrays i would like to compare my post data to if that helps.
$easy1 = array("4","3","5","2","6","9","7","8","1" );
$easy2 = array("6","8","2","5","7","1","4","9","3" );
$easy3 = array("1","9","7","8","3","4","5","6","2" );
$easy4 = array("8","2","6","1","9","5","3","4","7" );
$easy5 = array("3","7","4","6","8","2","9","1","5" );
$easy6 = array("9","5","1","7","4","3","6","2","8" );
$easy7 = array("5","1","9","3","2","6","8","7","4" );
$easy8 = array("2","4","8","9","5","7","1","3","6" );
$easy9 = array("7","6","3","4","1","8","2","5","9" );
all i want to do is use $_POST to compare my arrays from the first bit of code to a solution array. any advice is appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|