Jump to content

Recommended Posts

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:)

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.

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.