Shamsul Kamal
asked on
PHP form textarea array submission
Hi,
I would like to request an assistant.
I have the following textarea form , which is generated as array by php :
<textarea name='remark[]' id=$invoiceid cols='10' rows='1'>
</textarea>
<input type='submit' value='Go' name='SubmitRemark'>
I use the following PHP scripts to record :
if(isset($_POST['SubmitRem ark'])){
$textareaarray=$_POST['rem ark'];
$invoiceid=$_POST['invoice id'];
foreach($textareaarray as $textarea) {
$sql=mysql_query("UPDATE domainorder SET remark='$textarea', datepaid=NOW() WHERE invoiceid='$invoiceid' " , $conn);
if($sql){echo "<p><font face='Arial'><b>Domain DB Updated</b></font></p>";}} }
It seems the above php script not able to capture the post data and not record in the mysql.
Can anybody help to check and provide the complete new php scripts to handle textarea array ?
Appreciates anybody assistant.
Thank you.
I would like to request an assistant.
I have the following textarea form , which is generated as array by php :
<textarea name='remark[]' id=$invoiceid cols='10' rows='1'>
</textarea>
<input type='submit' value='Go' name='SubmitRemark'>
I use the following PHP scripts to record :
if(isset($_POST['SubmitRem
$textareaarray=$_POST['rem
$invoiceid=$_POST['invoice
foreach($textareaarray as $textarea) {
$sql=mysql_query("UPDATE domainorder SET remark='$textarea', datepaid=NOW() WHERE invoiceid='$invoiceid' " , $conn);
if($sql){echo "<p><font face='Arial'><b>Domain DB Updated</b></font></p>";}}
It seems the above php script not able to capture the post data and not record in the mysql.
Can anybody help to check and provide the complete new php scripts to handle textarea array ?
Appreciates anybody assistant.
Thank you.
"name='remark[]'" only works if you have more than one <textarea> with that name. A single <textarea> is not an array, it's just a string.
quick glance looks like that should work.
try the some helpful functions to troubleshoot
EG. var_dump()
comment out the db transactions using //
before the foreach try a vardump($textareaarray);
before the foreach try a vardump($invoiceid);
this will let you know if it is correctly collecting the values in the POST.
You can also covert your form from POST to GET to see the values in the url while your testing.
try the some helpful functions to troubleshoot
EG. var_dump()
comment out the db transactions using //
before the foreach try a vardump($textareaarray);
before the foreach try a vardump($invoiceid);
this will let you know if it is correctly collecting the values in the POST.
You can also covert your form from POST to GET to see the values in the url while your testing.
ASKER
The following is the output of var_dump($textareaarray);
array(98) {
[0]=>
string(5) "sdasd"
[1]=>
string(0) ""
[2]=>
string(0) ""
}
var_dump($invoiceid); return NULL .
Any hints ?
array(98) {
[0]=>
string(5) "sdasd"
[1]=>
string(0) ""
[2]=>
string(0) ""
}
var_dump($invoiceid); return NULL .
Any hints ?
ASKER
The above is the var_dump output , the following is the actual form :
<td>9</td>
<td>63350</td>
<td align='left'>smarttopup.bi z</td>
<td><font color=green>Yes</font></td >
<td>1</td>
<td><font color=red><b>Unpaid</b></f ont></td>
<td>0000-00-00 00:00:00</td>
<td> <input type='checkbox' name='checkbox[]' id='checkbox[]' value='63350'></td>
<td> <textarea name='remark[]' id=63350 cols='10' rows='1'></textarea><input type='submit' value='Go' name='SubmitRemark'></td>
</tr><tr>
<td>10</td>
<td>61532</td>
<td align='left'>clubasteriane twork.com< /td>
<td><font color=green>Yes</font></td >
<td>1</td>
<td><font color=red><b>Unpaid</b></f ont></td>
<td>0000-00-00 00:00:00</td>
<td> <input type='checkbox' name='checkbox[]' id='checkbox[]' value='61532'></td>
<td> <textarea name='remark[]' id=61532 cols='10' rows='1'></textarea><input type='submit' value='Go' name='SubmitRemark'></td>
</tr><tr>
<td>11</td>
<td>53681</td>
<td align='left'>ezytravel.net </td>
<td><font color=green>Yes</font></td >
<td>1</td>
<td><font color=red><b>Unpaid</b></f ont></td>
<td>0000-00-00 00:00:00</td>
<td> <input type='checkbox' name='checkbox[]' id='checkbox[]' value='53681'></td>
<td> <textarea name='remark[]' id=53681 cols='10' rows='1'></textarea><input type='submit' value='Go' name='SubmitRemark'></td>
</tr><tr>
<td>9</td>
<td>63350</td>
<td align='left'>smarttopup.bi
<td><font color=green>Yes</font></td
<td>1</td>
<td><font color=red><b>Unpaid</b></f
<td>0000-00-00 00:00:00</td>
<td> <input type='checkbox' name='checkbox[]' id='checkbox[]' value='63350'></td>
<td> <textarea name='remark[]' id=63350 cols='10' rows='1'></textarea><input
</tr><tr>
<td>10</td>
<td>61532</td>
<td align='left'>clubasteriane
<td><font color=green>Yes</font></td
<td>1</td>
<td><font color=red><b>Unpaid</b></f
<td>0000-00-00 00:00:00</td>
<td> <input type='checkbox' name='checkbox[]' id='checkbox[]' value='61532'></td>
<td> <textarea name='remark[]' id=61532 cols='10' rows='1'></textarea><input
</tr><tr>
<td>11</td>
<td>53681</td>
<td align='left'>ezytravel.net
<td><font color=green>Yes</font></td
<td>1</td>
<td><font color=red><b>Unpaid</b></f
<td>0000-00-00 00:00:00</td>
<td> <input type='checkbox' name='checkbox[]' id='checkbox[]' value='53681'></td>
<td> <textarea name='remark[]' id=53681 cols='10' rows='1'></textarea><input
</tr><tr>
ASKER
I think may be because of :
WHERE invoiceid='$invoiceid'
It can find the $invoiceid .
Any idea how to extract it from my form above ?
WHERE invoiceid='$invoiceid'
It can find the $invoiceid .
Any idea how to extract it from my form above ?
ASKER
I think may be because of :
WHERE invoiceid='$invoiceid'
It can't find the $invoiceid .
Any idea how to extract it from my form above ?
WHERE invoiceid='$invoiceid'
It can't find the $invoiceid .
Any idea how to extract it from my form above ?
Because you should extract a POST value from the name attribute, not id
$invoiceid=$_POST['remark' ];
(and change the remark[] to remark)
$invoiceid=$_POST['remark'
(and change the remark[] to remark)
ASKER
But if i change remark[] to remark it will no longer support array right ?
And how to capture the invoiceid from there as textarea value is something else ?
And how to capture the invoiceid from there as textarea value is something else ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i endup doing other way around .. separating checkbox and remarks form.