Jump to content

Pass Array From On Epage To Another


1885

Recommended Posts

I am having trouble passing an array from one page to another.

I want to do a data submission check and set the intial values to 0.

//**********************************************************************************************************

page 1:

<?php

session_start();

$inputs = array();

$v = array();

for($i=0; $i<13; $i++) {$v[$i] = 0; $inputs[$i] = 0; //set inputs to 0

 

echo "v = $v[$i] "; // debug

 

 

}

$_SESSION['inputs'] = '$inputs';

?>

<html>

</html>

//**********************************************************************************************************

page 2:

<?php

session_start();

$inputs = $_SESSION['inputs'];

 

//for($i = 0; $i < 13; $i++) echo "$v[$i] -";

for($i = 0; $i < 13; $i++) echo "$inputs[$i] -"; //debug

 

?>

<html>

Input 0

 

<FORM method="post" action="check-inputs.php">

. . .

Link to comment
Share on other sites

Wow. That was simple. It's been a few years since I've done some php.

It's nice to be coding again. Thanks for the help. I'm sure I'll need a lot more!

 

page 1

 

<?php

session_start();

 

 

$inputs = array();

$v = array();

for($i=0; $i<13; $i++) {$v[$i] = 0; $inputs[$i] = 0;

 

echo "v = $v[$i] ";

 

 

}

$_SESSION['inputs'] = $inputs;

$_SESSION['v'] = $v;

?>

<html>

 

 

page 2

 

<?php

session_start();

$inputs = $_SESSION['inputs'];

$v = $_SESSION['v'];

for($i = 0; $i < 13; $i++) echo "$v[$i] -";

for($i = 0; $i < 13; $i++) echo "$inputs[$i] -";

 

?>

<html>

Edited by 1885
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.