0

I have a php page with the following:

echo "<form method='post'><input type='hidden' id='memberIdd' name='memberIdd' value=" . $memberId . "></form>";

Now I created another php page and want to grab the value of this hidden field and place it into another variable. How can I do this? I tried using this for my second php page:

$member = $_POST['memberIdd'];

But I just keep getting "undefined" for $member.

Thanks

6
Contributors
6
Replies
10
Views
5 Years
Discussion Span
Last Post by hakeemtunde
0

Hey there,

Try using $_REQUEST ... if this isn't working, then try renaming the ID and NAME in your form.

0

Be sure to add an action to your form so it submits to the second script:

echo '<form method="post" action="script2.php"><input type="hidden" id="memberIdd" name="memberIdd" value=' . $memberId . '></form>';

You can then access the value as $_POST.

0

You don't need the ID attribute because when you use these $_GET or $_POST, they look for the name attribute. In your case, it is name='memberIdd'

Cheers,

0

You might want to try using GET for development, so you can see if anything shows up in the URL bar. If not, the problem is with the source page. If so, the problem is with the destination page.

The destination page should set $member to either $_GET[memberidd] or $_POST[memberidd] because you can't always control which method is used. Pseudocode:

if $_GET[...]
$member=$_GET[...]
else
if $_POST[...]
$member=$_POST[...]

make sense?

0

in the first place it like the form contains nothing important to send. if I were you I will just use session. hope you get what am saying.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.