Reply to Re: Help with $_POST and $_SERVER['PHP_SELF'] please.

Your name:

Reply:


Posted by Dynamo on 05/20/06 10:47

I kinda guessed that if I used a new php page that the original $_POST array
would be lost. However, I mistakenly thought that if I used $_SERVER['PHP_SELF']
as the action for the form that the array would still be stored. It appears that
that is not the case. So the problem remains of how to EASILY pass the array
from the first page to the next. I had already tried using

<input type="hidden" name="delete" value="<?php echo $_POST['delete']; ?>">

but it didn't work. When I debugged by using

<?php
echo "<pre>\n";
print_r($_POST['delete']);
echo "</pre>\n";
?>

on the second page all I got was the word "Array", hence when that was inserted
into the delete query I got

$query1 = "DELETE FROM Catalogue WHERE id = Array"

So I'm hazarding another guess that my hidden field input should be something
morelike this
<?php
for each (value stored in the array){
?>
<input type="hidden" name="delete[]" value="<?php echo (value stored in array);
?>">
<?php
}
?>

Only problem is I'm not sure what goes into the (value stored in array) part of
the code. Any help greatly appreciated. Is there an easier way of passing the
array?

Regards
Dynamo





In article <pan.2006.05.20.02.37.48.82620@bens-house.org.uk>, Ben Holness
says...
>
>Dynamos comments are totally valid, but on the basis that you stripped all
>that stuff out, you just need to add a hidden input here to make it work...
>
>(Note: Example typed and not tested)
>
>> <?php
>> $delete = '( id = ' . implode(' OR id = ', $_POST['delete'] ) . ' ) ';
>> if (!isset($_POST['submit']))
>> {
>> // Then display the records that were marked for deletion ?>
>> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
>
>** Hidden input here **
><input type="hidden" name="delete" value="<?php echo $_POST['delete']; ?>">
>
>> <p> align="center"><font face="Arial" size="2"><b>Are you sure you wish to
>> continue?</b></font></p>
>> <p align="center"><input type="submit" name="submit" value="Yes I want
>> to delete these records"></p>
>> </form>
>
>[snip]
>
>
>Cheers,
>
>Ben

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация