views:

68

answers:

2

I have a page that allows the user to draw an image using HTML5 canvas, convert it into text with JavaScript and post it to a PHP page.

http://dsiextensions.co.cc/chatdraw.php The page is quite confusing, each text box is for each line of to 100px X 100px canvas. To put the data in the boxes, click "Finish" and then click "Submit" (Sorry that it's really slow).

I've tries making changes to the PHP code and occasionally the variable turns up but more often than not, it doesn't.

Here's the code: (note, only the data in the first box is used at the moment)

<?php
$dstring = $_POST['senddata1'];
$darray = str_split($dstring);
echo $dstring;
print_r($darray);

$x=1;
$y=1;
for ($a=0;$a<100;$a++)
{
    if($a%100==0 && $a!=0){
        echo '&#60;br /&#62;'; //Checks if it is the 100th pixel and adds a new line  (not needed at the moment)
        $y++;
        $x=1;}

        //echo $x . ',' . $y . '(' . $a . ',' . $darray[$a] . ')|';

        if($darray[$a]!=0){
            echo "<input type='button' style='width:15;height:15;background-color:#000' />"; //Black button if it is a black pixel
        }
        else{
            echo "<input type='button' style='width:15;height:15;background-color:#fff' />"; //White button if it is a white pixel
        }

        $x++;
}
?>

The codes supposed to check if the pixel is black or white and create a coloured button based on that (I'm going to use the image functions later), however $dstring is never echoed and therefore can't be converted to an array. Is there something I'm doing wrong here or is it a server problem?

Thanks

A: 

Note that the second PHP line should be spread out on to three lines

Tom Col
The formatting has since been edited :)
Matchu
A: 

Seems to work by my side. Are you sure that data is well posted ? Try to make a print_r($_POST); in your script to see what has been posted

Serty Oan