Jump to content

unserialize / serialize


proctk

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]
Link to comment
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...
Link to comment
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...
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.