_spaz Posted September 24, 2009 Share Posted September 24, 2009 I'm having issues passing an array result thru a form to another PHP page...I've tried a few things and can't figure it out. I have a series of array results like so: alert[0]= "image 1" alert[1]= "image 2" alert[2]= "image 3" I would like to be able to have a user form input box to select say alert[1] by pressing "1" on the main.php page and push that array result to showimage.php. Not sure if the below is correct in any way shape or form.... <form action="showimage.php" method="post"> Enter Alert #: <input type="text" name="arrayresult"/> <input type="hidden" name="image" value="<?=$alert[$arrayresult];?>"/> <input type="submit" /> </form> Any help would be great, i've received some great help for other issues already... wish i came to you guys earlier:) Quote Link to comment https://forums.phpfreaks.com/topic/175429-passing-array-result-to-another-php-page/ Share on other sites More sharing options...
DanC Posted September 24, 2009 Share Posted September 24, 2009 You could try putting it in a session variable. if(isset($_POST['arrayresult'])) { $_SESSION['carryover'] = $alert[$arrayresult]; } Then call it on the other page. echo $_SESSION['carryover']; EDIT: I see what you are trying to do, and realised it is a lot more tricky than I thought. Sessions would be one way of carrying over the result, as well as $_POST, but i'm not too sure how to get it to select between the arrays and send it. Quote Link to comment https://forums.phpfreaks.com/topic/175429-passing-array-result-to-another-php-page/#findComment-924486 Share on other sites More sharing options...
mikesta707 Posted September 25, 2009 Share Posted September 25, 2009 define the array on showimage.php and with the post variable arrayresult do the following echo $alert[$_POST['arrayresult']]; if you cant define the array on showimage.php then pass it through the session, or serialize it and pass it through a post variable (though I would just pass it through the session) Quote Link to comment https://forums.phpfreaks.com/topic/175429-passing-array-result-to-another-php-page/#findComment-924511 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.