我有一个页面允许用户使用HTML5画布绘制图像,使用JavaScript将其转换为文本并将其发布到PHP页面。
http://dsiextensions.co.cc/chatdraw.php 该页面非常混乱,每个文本框用于100px X 100px画布的每一行。要将数据放入框中,请单击“完成”,然后单击“提交”(很抱歉,它确实很慢)。
我尝试对PHP代码进行更改,偶尔会出现变量,但通常不会,但事实并非如此。
以下是代码:(注意,目前仅使用第一个框中的数据)
<?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 '<br />'; //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++;
}
?>
代码应该检查像素是黑色还是白色,并根据它创建一个彩色按钮(我稍后将使用图像功能),但$ dstring永远不会被回显,因此无法转换为数组。我在这里做错了什么或是服务器问题?
由于
答案 0 :(得分:0)
请注意,第二行PHP应分散到三行
答案 1 :(得分:0)
似乎在我身边工作。你确定数据发布得好吗?尝试在脚本中创建print_r($_POST);
以查看已发布的内容