Jump to content


Photo

unserialize / serialize


  • Please log in to reply
5 replies to this topic

#1 proctk

proctk
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts

Posted 14 April 2006 - 06:15 PM

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

// 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 attached to the summary page



<?
$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"];
?>



#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 14 April 2006 - 10:42 PM

Your form page is using the POST method, while your summary page is using the GET method

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 proctk

proctk
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts

Posted 14 April 2006 - 11:08 PM

Thank you for the reply,

I changed the summary page to post and nothing changed

#4 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 14 April 2006 - 11:47 PM

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)

if (button == yes) {
 display summary;
}else {
 do something else;
}

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#5 proctk

proctk
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts

Posted 15 April 2006 - 12:11 AM

Thank you for the relpy, I'm way to new at this and don't really undersand what you want me to do

#6 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 15 April 2006 - 12:57 AM

Ok rather than writing the code for you, we are trying to make the concepts clear.

try these two simple files.


<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>


<?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
} 
?>


Hope this isn't too muddy.

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users