Hi again,
I've been busy over the last few days in other forums, trying to figure this out. I felt like a bit of an idiot at first, but others are getting confused by this too - I don't see the part of the docs which deal with this submit button.
Maybe I'm missing some php basics, but it's been a week of struggling here.
Got a seemingly unique problem with concatenating form variables + the name of the button used to submit.
This works:
$word="number"; $number=1; myalbum=$word.$number;
echoing $myalbum gives "number1". No surprises there.
BUT if I POST the form to a php script with the intention of writing to file ONLY the data on row on which the button was pushed, I get problems.
So, let's say I've got 10 rows, and the button for row 5 is pushed. If I get the script to echo what button was pushed ($button), I get "5" back. If I get the script to echo what's in the box in row 5 (in this case, "$number5=5") then by echoing $number5 I get 5.
But if I concatenate $number.$button, I get nothing, when I expect "number5". And yet, if I concat any two parts of the submitted data, it works as expected.
I've been over the variables section at php.net, I've been over the w3 forms tutorials. I've googled. . I've checked and triple checked my spelling.
I even started from scratch - again, it's almost as if appending the value of the button kills the concatenation process.
The output from the form: preset1=Name+of+preset+1&url1=
http://example.com/1&preset2=Name+of+preset+2&url2=http://example.com/2&preset3=Name+of+preset+3&url3=http://example.com/3The code for the form handler:
<?php
$myFile = "test.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "Preset: " . $preset . " - Title:" . $title . $submitButton . " - Submit Button:" . $submitButton . "
";
fwrite($fh, $stringData);
fclose($fh);
?>
The output from the above: Preset: 3 - Title:3 - Submit Button:3
So, we know it knows what buttons has been pressed. But not the output I expected.
But if I change the line to $stringData = "Preset: " . $preset3 . " - Title:" . $title3 . " - Submit Button:" . $submitButton . "
";
then I get, as expected: Preset: Name of preset 3 - Title:
http://www.example.com/3 - Submit Button:3
But of course, this is no good. I understood that if $preset.$submitButton would be the same as $preset3 if submitButton was 3.
Oh, and I've also tried $thepreset='$title' . $submitbutton; and then using that - all I get is "Title:$title"
Then someone suggested I try:
"$preset[$submitButton] - Rework the problem using submitButton as your array key."
and someone else suggested:
"Shouldn't this be: echo $_POST[$preset.$submitButton];"
But again, none of those give me anything more than either "3" or "$preset3", not the actual contents of preset3.
You see, as it doesn't appear possible to submit only part of the form, my idea was to get the form handler itself to do that part.