473,504 Members | 13,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Values not passing to second form.

TG
Conditions:
Register globals is set to on.
Parse html as php is set to on.

I have two forms OrderTest1 and OrderTest2 and need to be able to validate
the data from OrderTest1 before passing to OrderTest2. The first block of
code below is the first form. This form calls itself and does perform the
validations correctly as I want. However, once the header redirect to
OrderTest2.htm is performed after the isset($POST['submit'])) evaluates as
true indicating the values have been posted, I'm redirected to
OrderTest2.htm but the values entered do not display. Why?

If the redirect eliminates the posted variables, how can I perform a
validation within a form that posts to itself then pass posted values to a
second form? Obviously the values are not passed even though they should be
global variables at this point. How can I successfully pass values posted to
the first form to the second form after the header location command is
called?

Help!

================================================== ===
OrderTest1.htm
================================================== ===
<?php
if(isset($_POST['submit']))
{

$successflag="true";
if ((trim($fullname)=="") && isset($fullname))
{
$successflag="false";
}
if($successflag=="true")
{
Header("location: OrderTest2.htm");
exit;
}

}

?>

<!--************************************************** ***************-->
<!--************************************************** ***************-->
<!--************************************************** ***************-->

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>

<form method="post" action="<?php $server['PHP_SELF']?>">

<b>fullname:</b> <input type="text" name="fullname" size="49">

</body>
</html>

================================================== ===
OrderTest2.htm
================================================== ===
<?php
echo "Test";
echo $_POST['fullname'];
echo $HTTP_POST_VARS['fullname'];
?>
<html>
<head>
</head>
<body>
<p>&nbsp;</p>
</body>
</html>
Jul 17 '05 #1
5 5087
TG
Please review this piece of code. The last one I listed did not include the
submit button for the OrderTest1.htm form. Again, none of the values print
out in OrderTest2.htm that were posted to in OrderTest1.htm. If values
cannot be seen by another form after a post even if they are defined as
globals, how can values be passed to and displayed within the OrderTest2.htm
form.
================================================== ===
OrderTest1.htm
================================================== === <?php
if(isset($_POST['submit']))
{

$successflag="true";
if ((trim($fullname)=="") && isset($fullname))
{
$successflag="false";
}
if($successflag=="true")
{
$fullname=$HTTP_POST_VARS['fullname'];
Header("location: OrderTest2.htm");
exit;
}

}

?>

<!--************************************************** ***************-->
<!--************************************************** ***************-->
<!--************************************************** ***************-->

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>

<form method="post" action="<?php $server['PHP_SELF']?>">

<b>fullname:</b> <input type="text" name="fullname" size="49">
<p align="center"><input
type="submit" name="submit" value="submit"></p>

</form>
</body>
</html> ================================================== ===
OrderTest2.htm
================================================== ===

<?php
echo $fullname;
echo $_POST['fullname'];
echo $HTTP_POST_VARS['fullname'];
?>
<html>
<head>
<meta name="generator" content="Namo WebEditor v5.0(Trial)">
</head>
<body>
<p>&nbsp;</p>
</body>
</html>
Jul 17 '05 #2
TG wrote:

TG:
*quick note: when using the location header, always specify a full url
(http://....) as many browsers will not work with relative urls.

The problem is that, for some reason, you insist on breaking the form across
multiple files. When you do header("Location: OrderTest2.htm"); you do not
pass *any* form data. (Tried to convey this in the other thread..) e.g. the
values in $_POST (fullname etc) are only in $_POST on ordertest1.

Solutions:
a) Pass the variables to OrderTest2 somehow (poor)
b) use sessions to temporarily store the data
c) keep it all on one page. (best solution). If the first part of the form
data validates ($successflag) then display the second part of the form. [by
the way - comparing a boolean value to a string "true" is crazy. just do if
($successflag).] if it doesn't validate (!$successflag) then display the
first part of the form, and not the second.
Jul 17 '05 #3
TG
Agelmar:
Solutions:
a) Pass the variables to OrderTest2 somehow (poor)
b) use sessions to temporarily store the data
c) keep it all on one page. (best solution). If the first part of the form
data validates ($successflag) then display the second part of the form. [by the way - comparing a boolean value to a string "true" is crazy. just do if ($successflag).] if it doesn't validate (!$successflag) then display the
first part of the form, and not the second.


Okay,

Bear with me.... I'm trying your approach (b) above -- session variables.
I've created these simple test scripts below. Note: in form one I start a
session, assign a value to a session variable, I then do a header redirect
to a second page. Nothing displays on the second page. If I however
uncomment out the href statement below the location command and comment out
the header command the session variables are printed on the second form.
What a pain in the 'A' the header location command is! Perhaps I don't
understand how session variables function. Aren't these session variables
assigned before the header location command in my code? Does the header
location command undo the session assignment command?
==================================
Basic form test page one
==================================
<?php
session_start();
$_SESSION['myvar']=5;
echo $_SESSION['myvar'];
Header("location: xxxxxxxxxxxxxxxxx");
exit;
//print("<a href=http://xxxxxxxxx>click here<a\>");
?>
==================================
Basic form test page two
==================================
<?php
session_start(); //// You must have this to call variables from prev form
echo $_SESSION['myvar'];
?>
Jul 17 '05 #4
TG wrote:
Agelmar:
Solutions:
a) Pass the variables to OrderTest2 somehow (poor)
b) use sessions to temporarily store the data
c) keep it all on one page. (best solution). If the first part of
the form data validates ($successflag) then display the second part
of the form. [by the way - comparing a boolean value to a string
"true" is crazy. just do if ($successflag).] if it doesn't validate
(!$successflag) then display the first part of the form, and not the
second.


Okay,

Bear with me.... I'm trying your approach (b) above -- session
variables. I've created these simple test scripts below. Note: in
form one I start a session, assign a value to a session variable, I
then do a header redirect to a second page. Nothing displays on the
second page. If I however uncomment out the href statement below the
location command and comment out the header command the session
variables are printed on the second form. What a pain in the 'A' the
header location command is! Perhaps I don't understand how session
variables function. Aren't these session variables assigned before
the header location command in my code? Does the header location
command undo the session assignment command?


My guess is you have cookies disabled. php will try to store a cookie with
the sessionid in the browser. If it can't, and enable_trans_sid is enabled,
it will append something like ?PHPSESSID=.... to any href. You might try the
following:

header("Location: http://xxxxxx?".strip_tags(SID));
(and yes, the ? should be in there. e.g:
header("Location: http://www.mysite.com/form2.php?".strip_tags(SID));

http://www.php.net/manual/en/ref.ses...sion.idpassing has some info
on it (and explains [albeit briefly] why the strip_tags is in there)
Jul 17 '05 #5
TG
Bingo. Now we're dealing. Your right I kept getting cookie errors. I thought
it was probably a configuration issue because my script was right. Let me
try review this.
"Agelmar" <if**********@comcast.net> wrote in message
news:bt************@ID-30799.news.uni-berlin.de...
TG wrote:
Agelmar:
Solutions:
a) Pass the variables to OrderTest2 somehow (poor)
b) use sessions to temporarily store the data
c) keep it all on one page. (best solution). If the first part of
the form data validates ($successflag) then display the second part
of the form. [by the way - comparing a boolean value to a string
"true" is crazy. just do if ($successflag).] if it doesn't validate
(!$successflag) then display the first part of the form, and not the
second.

Okay,

Bear with me.... I'm trying your approach (b) above -- session
variables. I've created these simple test scripts below. Note: in
form one I start a session, assign a value to a session variable, I
then do a header redirect to a second page. Nothing displays on the
second page. If I however uncomment out the href statement below the
location command and comment out the header command the session
variables are printed on the second form. What a pain in the 'A' the
header location command is! Perhaps I don't understand how session
variables function. Aren't these session variables assigned before
the header location command in my code? Does the header location
command undo the session assignment command?


My guess is you have cookies disabled. php will try to store a cookie with
the sessionid in the browser. If it can't, and enable_trans_sid is

enabled, it will append something like ?PHPSESSID=.... to any href. You might try the following:

header("Location: http://xxxxxx?".strip_tags(SID));
(and yes, the ? should be in there. e.g:
header("Location: http://www.mysite.com/form2.php?".strip_tags(SID));

http://www.php.net/manual/en/ref.ses...sion.idpassing has some info on it (and explains [albeit briefly] why the strip_tags is in there)

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4246
by: TG | last post by:
Dear PHP Group, I have two forms that are used to collect user information. The first one takes user inputted values such as fullname, city, address etc. I want these values to display in the...
3
14907
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
1
9705
by: Al Jans | last post by:
Hi, I'm having a problem passing a value from a field on one form to another field on another form. The value is being passed between forms, however it's not being displayed and i've got no idea...
8
1953
by: Chris | last post by:
Hi, I have two froms (form1 and form2). I want to be able to pass values from form 1 to form2 and be able to use those values leter in form2. This is my code for form1 Private Sub...
11
3211
by: joey.powell | last post by:
Hello, I have a windows forms application (VS2005) where I need to do the following... 1. Startup with a main form. 2. Have the user to select a file and then bring up a second form modally...
3
4945
by: gw.boswell | last post by:
I have created a userform with textboxes for data entry. I also have a command button that calls a second useform. A user enters certain information in the first useform but if he/she wants to do...
10
3655
by: Girish | last post by:
Hi Everyone, I am passing a form to a php script for further processing. I am able to retrieve the last value set for that given form variable using $variable=$_REQUEST;
5
3533
vanc
by: vanc | last post by:
I read many articles about this problem, but I found out that to pass values between one created form and one is not yet is created is fairly simple, it can be done by assign value to public variable...
0
1181
by: SanjayKumarDey | last post by:
I have a vb.net datagrid bound to a dataview on a windows form. I want to use the datagrid to display and filter a list of items , but since the data is complex, I don't want the user to edit the...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.