Jump to content

Insert session variable into form


sporks

Recommended Posts

I've set a session variable that spits out the ID of the previous page.  There is a hidden field on my insert form which I've set to equal the session variable.  I have the variable echoing so I know it works but if you insert the form, the field shows up as null.  What is wrong with my field?

 

<input type="hidden" name="pastID" value="<?php $_SESSION['fromID'] ?>" />
  <input type="hidden" name="MM_insert" value="form1" />

 

Also I have a repeating region spitting out text and I wanted to place the word 'or' between each one.  Is there a way I can put something in between a repeating region without it that something also on the end.

 

ie NOT: 'field one' or 'field two' or

Link to comment
Share on other sites

Well the problem with the value in your input being null is happening because you're not echoing the session variable. Try this:

<input type="hidden" name="pastID" value="<?php echo $_SESSION['fromID']; ?>" />

Link to comment
Share on other sites

If you are using a while loop you could do something like this:

<?php
$x = 0
while (what ever your condition is)
{
if ($x != "0")
{
echo "or";
}

//your repeating title code here

$x++;
}
?>

 

This will place 'or' before every title except when $x is equal to 0 which is only on the first loop so no 'or' will appear before the first title.

Note: You can do this with any loop, I just used while as an example.

 

I hope that solved all your problems  ;)

Link to comment
Share on other sites

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.