Jump to content

Archived

This topic is now archived and is closed to further replies.

proctk

unserialize / serialize

Recommended Posts

HI

I have a form on my web page that has a link at the bottom which opens a summary page. my goal is to display the data from the form on the summary page.

The code below somewhat works but when the link is clicked nothing displays on the summary page. when the button is clicked it cleares the data on the form, what to leave the data in the form fields.

I believe the issue has something to do with the code on the summary page, as all the values are transfered to the adress bar when the submit button is clicked

Any help is great

thank you



the below code it attached to the bottom of the form
[code]

// form code
<form id="horizontalForm" name="ded" method="POST">
<input id="submit" type="submit" value="Calculate" onclick="compute(this.form)" />
//------------

<?
echo "<a href='testpage.php?data=", serialize($_POST), "'>Summary</a>";
?>
[/code]

code attached to the summary page

[code]


<?
$data = $_Get["data"];
$values = unserialize($data);
//$values has all the posted info from the previous page, in array form
//$eiLastDate = $values["eiLastDate"];
//$values["y"]
//etc...
echo $values["eiLastDate"];
?>

[/code]

Share this post


Link to post
Share on other sites
Your form page is using the POST method, while your summary page is using the GET method

Share this post


Link to post
Share on other sites
Thank you for the reply,

I changed the summary page to post and nothing changed

Share this post


Link to post
Share on other sites
ok, had my meds and a glass of wine, ready to do battle (from the movie michael).

I could be mistaken (its happened twice - once in 1953 and once in 1979) but when you click on the Summary link, for all intent and purposes, the data in the form is NOT submitted.

As an experiment, do the following...

1. test form page that uses same fields BUT do not have the summary button/link. Instead, make an extra data field (a check box perhaps) that the user checks if they want to see a summary.

2. make the process page get the variables from the form using the POST method.

3. in the process page, IF the summary field has been checked, then display the summary. Else do your other processing.


ie (psuedo php)

[code]
if (button == yes) {
display summary;
}else {
do something else;
}[/code]

Lite...

Share this post


Link to post
Share on other sites
Thank you for the relpy, I'm way to new at this and don't really undersand what you want me to do

Share this post


Link to post
Share on other sites
Ok rather than writing the code for you, we are trying to make the concepts clear.

try these two simple files.


[code]<html>
<head>
<title>test form</title>
</head>
<body>

Once you understand what is happening, modify this page to get the data you want

<form action="testform01.php" method="post">
first name: <input type="text" name="firstname" size="40" maxlength="80" value=""><br>
last name: <input type="text" name="lastname" size="40" maxlength="80" value=""><br>
check this if you would like to see a summary: <input type="checkbox" name="showsummary" value="1"><br>
<input type="submit" value="Submit">
</form>

</body>
</html>[/code]


[code]<?PHP

#####################
# this is the test form page 2
#
$showsummary = $_POST['showsummary'];
$firstname =  $_POST['firstname'];
$lastname =  $_POST['lastname'];



if (isset($showsummary)) {
    echo "The checkbox was clicked <br>";
    echo "Your name is " . $firstname . " " . $lastname;
    //display your summary here
} else {
    echo "The checkbox wasn't clicked";
    // do something else
}
?>[/code]


Hope this isn't too muddy.

Lite...

Share this post


Link to post
Share on other sites

×

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.