Hello,
I have made a simple form, which displays an input first, you have to enter a number, then a dynamic form show up with a dynamic part where the number and name of fields vary depending on the number entered first.
In the action page, i have a problem, when i try to display the data in each field, i don't succeed, i get a message
Notice: Array to string conversion
My code is the following :
<h1>Training Reports</h1>
<hr />
<form action="" method="post">
Type the number of SEALs : <input type="number" name="nofseals"/>
<input type="submit" name="submitn" value="Submit" />
</form>
<?php
if(isset($_POST['submitn'])){
$numberofseals=$_POST['nofseals'];
$numberoffields = 0;
echo "<form name=\"report\" action=\"reporta.php\" method=\"post\" style=\"text-align:left;\">
<div style=\"margin-left: 50%;\">Training #
<input type=\"number\" name=\"number\"/></div>
<br><br>
<input type=\"number\" name=\"nos\" value=\"$numberofseals\" style=\"display: none;\"/>
<input type=\"number\" name=\"nof\" value=\"$numberoffields\" style=\"display: none;\"/>
<h3>Date</h3>
<input type=\"date\" name=\"date\" placeholder=\"Date\"/>
<h3>Training Type</h3>
<textarea name=\"type\" rows=\"2\" placeholder=\"Training Type...\" ></textarea>
<h3>Training Duration</h3>
<input type=\"time\" name=\"duration\" placeholder=\"Training Duration\"/>
<h3>Training Details</h3>
<textarea name=\"details\" rows=\"8\" placeholder=\"Training Details...\" ></textarea>
<h3>Screenshots</h3>
<textarea name=\"ss\" rows=\"1\" placeholder=\"Screenshots links...\" ></textarea>
<h2>Participants Marks and Comments</h2>";
while ($numberoffields < $numberofseals) {
$numberoffields++;
echo "<h3>SEAL $numberoffields : <input type=\"text\" name=\"n[$numberoffields]\" placeholder=\"SEAL Name\"/></h3>
<div style=\"margin-left: 20px;\">
Behavior :<input type=\"text\" name=\"b[$numberoffields]\" placeholder=\"Behavior Mark\"/><br>
Skills: <input type=\"text\" name=\"m[$numberoffields]\" placeholder=\"Skills Mark\"/><br>
Comments: <textarea name=\"c[$numberoffields]\" rows=\"1\" placeholder=\"Comments\"></textarea></div>
<br><br>";}
echo "<input type=\"submit\" name=\"submit\" value=\"Submit\" />";}
?>
Action page :
<?php
if(isset($_POST['submit'])){
$noofseals=$_POST['nos'];
$number=$_POST['number'];
$date=$_POST['date'];
$type=$_POST['type'];
$details=$_POST['details'];
$duration=$_POST['duration'];
$ss=$_POST['ss'];
$numero=0;
$c{$numero}=$_POST['c'];
$m{$numero}=$_POST['m'];
$b{$numero}=$_POST['b'];
$n{$numero}=$_POST['n'];
echo "[center][color=#2D3C0F][size=20pt][glow=black,2,100][font=georgia]TRAINING REPORT #[/font][/glow][/size][/color][/center]
[b][color=navy]Date:[/color][/b]$date
[b][color=navy]Type of training:[/color][/b]$type
[b][color=navy]How long it lasted:[/color][/b]$duration
[b][color=navy]Training details:[/color][/b]$details
[b]Screenshots:(optional)[/b]$ss
[b][color=navy]SEALs perfomance[/color][/b]
[list]";
while($numero < $noofseals) {
$numero++;
echo "[li][b][color=blue]Seal [$nn]:[/color][/b]
[b]Behavior:[/b]
[b]Skills:[/b]
[b]Comments:[/b]
[/li]";
}}
echo"[/list]";
?>