I want to echo part of an array ‘name’ and then have a submit button next to it which redirects to a new page which echos the rest of the array eg. address, phone number ect. but the information gets lost when redirected. is there some way around this. This code should explain what I’m getting at.
Page 1:
<?php
$info = mysql_query ("SELECT * FROM table WHERE name= 'something'");
$info = mysql_fetch_assoc($info));
?>
<html>
<form action='page2.php' method='POST'>
<?php echo $info['name']; ?>
<input type='submit' value='see other details'>
</form>
</html>
Page 2:
<?php
echo $info['address'].$info['address'].$info['address'];
?>
Yes, use the PHP session. Store your array as
$_SESSION['info'], and it will become available on the next page. Don’t forget tosession_start()on both pages.Page 1:
Page 2: