By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,166 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,166 IT Pros & Developers. It's quick & easy.

Values not displaying in second form after post.

P: n/a
TG
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 second form when it is called. Both forms are .htm
files that call themselves when the submit button is press via the following
command in each form:

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

The server is set to parse .htm files as php. Everything else is working
fine and all the validation checks are working fine. Based on certain
validation checks that are within the form php code, the user is either left
on the input form page to correct errors or if there are no errors the user
is passed to the next form via a Java call....

<script language="javascript">
<!--
location.replace("order2.htm");
-->
</script>

I have even put a session_write_close() before the redirect hoping this
would fix the problem of not displaying the inputted values from the first
form into the second form.

The server value for global variables is set to ON.

In the second form I have tried to display the values from the first form
after the POST using the following three methods:

$fullname;
echo $HTTP_POST_VARS['fullname'];
echo $_POST['fullname'];

Nothing works...

Any ideas why I cannot get the values from the first form to display on the
second form?

Thanks in advance!
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
TG <tg********@cox.net> wrote:
<form method="post" action="<?php $server['PHP_SELF']?>">

The server is set to parse .htm files as php. Everything else is working
fine and all the validation checks are working fine. Based on certain
validation checks that are within the form php code, the user is either left
on the input form page to correct errors or if there are no errors the user
is passed to the next form via a Java call....
Java/Javascript, what's the difference :)
<script language="javascript">
<!--
location.replace("order2.htm");
-->
</script> In the second form I have tried to display the values from the first form
after the POST using the following three methods:

$fullname;
echo $HTTP_POST_VARS['fullname'];
echo $_POST['fullname'];

Nothing works...


No kidding, just the javascript code above will not submit any form
parameters to your script. There is _no_ reason to use above js code.

Move[1] the checks to the serverside and do redirect (if needed) there.

[1] nothing wrong with clientside checks but don't rely on them for
validation and flowcontrol.

--

Daniel Tryba

Jul 17 '05 #2

P: n/a
TG
OK

Let me further explain. I have logic in the PHP code within the input form
that displays information within the form about fields that have been
entered in error. If I move the checks to the server side won't I leave the
form and I won't get those error messages displayed on that particular form.

In other words. I have a form that users put input into. I don't want the
user to be directed to an error screen created by a PHP script that forces
the user to move back to the user input form. I want to keep the user within
that particular form until all the values entered are correct. I have yellow
warning messages that display within the form next to the fields that are in
error. I DO NOT want to leave the form. It must be redirected to itself.

I guess I'm not following. The check IS performed on the server. The PHP
runs on the server. The form only has one call to Javascript and that is a
redirect it is not validation.

I have NO client side validations at all! Client side checks would be if I
were using Javascript and the only call I make to Javascript is after a POST
is initiated within PHP. All the checks work correctly when the POST is
executed . The user is directed to the new HTML form no data is displayed

BTW I just tried the following test....

I used the following code below WITHOUT any Javascript

if (isset($fullname))
{
header("location: order2.htm");
exit; //// Necessary to ensure code below does not get executed when
redirecting
}

This has worked for me in the past passing values after a post. This doesn't
even work!

"Daniel Tryba" <ne****************@canopus.nl> wrote in message
news:bt**********@news.tue.nl...
TG <tg********@cox.net> wrote:
<form method="post" action="<?php $server['PHP_SELF']?>">

The server is set to parse .htm files as php. Everything else is working
fine and all the validation checks are working fine. Based on certain
validation checks that are within the form php code, the user is either left on the input form page to correct errors or if there are no errors the user is passed to the next form via a Java call....


Java/Javascript, what's the difference :)
<script language="javascript">
<!--
location.replace("order2.htm");
-->
</script>

In the second form I have tried to display the values from the first form after the POST using the following three methods:

$fullname;
echo $HTTP_POST_VARS['fullname'];
echo $_POST['fullname'];

Nothing works...


No kidding, just the javascript code above will not submit any form
parameters to your script. There is _no_ reason to use above js code.

Move[1] the checks to the serverside and do redirect (if needed) there.

[1] nothing wrong with clientside checks but don't rely on them for
validation and flowcontrol.

--

Daniel Tryba

Jul 17 '05 #3

P: n/a
TG wrote:
OK

Let me further explain. I have logic in the PHP code within the input
form that displays information within the form about fields that have
been entered in error. If I move the checks to the server side won't
I leave the form and I won't get those error messages displayed on
that particular form.
That's fine...
In other words. I have a form that users put input into. I don't want
the user to be directed to an error screen created by a PHP script
that forces the user to move back to the user input form. I want to
keep the user within that particular form until all the values
entered are correct. I have yellow warning messages that display
within the form next to the fields that are in error. I DO NOT want
to leave the form. It must be redirected to itself.
The php page that processes the values does not have to be a separate page,
and the users do not have to be redirected to an error page. It is entirely
possible to keep the user at the same page...
I guess I'm not following. The check IS performed on the server. The
PHP runs on the server. The form only has one call to Javascript and
that is a redirect it is not validation.
But your redirect will not allow *any* of the values to be processed, as
when you call "location: ..." none of the form values are passed.
I have NO client side validations at all! Client side checks would be
if I were using Javascript and the only call I make to Javascript is
after a POST is initiated within PHP. All the checks work correctly
when the POST is executed . The user is directed to the new HTML form
no data is displayed

BTW I just tried the following test....

I used the following code below WITHOUT any Javascript

if (isset($fullname))
{
header("location: order2.htm");
exit; //// Necessary to ensure code below does not get executed when
redirecting
}

This has worked for me in the past passing values after a post. This
doesn't even work!


probably because you have already outputted something before the header()
call. Look, I have no idea what the hell you are using javascript at all
for, the following is all you need.
--- beginning of file---
<?php
if (isset($_POST['fullname']))
{
// process the data, see if it's valid.
// if it's valid and you're satisfied, do whatever you want with the
data
// (add it to a database or whatever), and then:
// header("Location: http://www.mysite.com/page2.php");
// (be sure not to output anything, including blank
// lines or spaces before the <?php
// before the call to header()
// if you're not satisfied with the data, start outputting the form
again
echo "<form name=....";
echo '<input type="text" name="fullname"
value="',htmlspecialchars($_POST['fullname']),'"><br>';
//....
}
else {
// display the form for the first time
echo "<form name=....";
echo '<input type="text" name="fullname"><br>';
}

?>
--- end of file ---
Jul 17 '05 #4

P: n/a
TG
Thanks for the inputs. No -- I'm not outputting anything before the header
and get no error messages. What is so confusing is that this was working
with the header redirect before. And yes I have seen logic similar to this
snippet you attached below.... I'll definitely use it in hopes it fixes this
problem!

Thanks again!

<?php
if (isset($_POST['fullname']))
{
// process the data, see if it's valid.
// if it's valid and you're satisfied, do whatever you want with the
data
// (add it to a database or whatever), and then:
// header("Location: http://www.mysite.com/page2.php");
// (be sure not to output anything, including blank
// lines or spaces before the <?php
// before the call to header()
// if you're not satisfied with the data, start outputting the form
again
echo "<form name=....";
echo '<input type="text" name="fullname"
value="',htmlspecialchars($_POST['fullname']),'"><br>';
//....
}
else {
// display the form for the first time
echo "<form name=....";
echo '<input type="text" name="fullname"><br>';
}

?>
"Agelmar" <if**********@comcast.net> wrote in message
news:bt************@ID-30799.news.uni-berlin.de...
TG wrote:
OK

Let me further explain. I have logic in the PHP code within the input
form that displays information within the form about fields that have
been entered in error. If I move the checks to the server side won't
I leave the form and I won't get those error messages displayed on
that particular form.
That's fine...
In other words. I have a form that users put input into. I don't want
the user to be directed to an error screen created by a PHP script
that forces the user to move back to the user input form. I want to
keep the user within that particular form until all the values
entered are correct. I have yellow warning messages that display
within the form next to the fields that are in error. I DO NOT want
to leave the form. It must be redirected to itself.


The php page that processes the values does not have to be a separate

page, and the users do not have to be redirected to an error page. It is entirely possible to keep the user at the same page...
I guess I'm not following. The check IS performed on the server. The
PHP runs on the server. The form only has one call to Javascript and
that is a redirect it is not validation.


But your redirect will not allow *any* of the values to be processed, as
when you call "location: ..." none of the form values are passed.
I have NO client side validations at all! Client side checks would be
if I were using Javascript and the only call I make to Javascript is
after a POST is initiated within PHP. All the checks work correctly
when the POST is executed . The user is directed to the new HTML form
no data is displayed

BTW I just tried the following test....

I used the following code below WITHOUT any Javascript

if (isset($fullname))
{
header("location: order2.htm");
exit; //// Necessary to ensure code below does not get executed when
redirecting
}

This has worked for me in the past passing values after a post. This
doesn't even work!


probably because you have already outputted something before the header()
call. Look, I have no idea what the hell you are using javascript at all
for, the following is all you need.
--- beginning of file---
<?php
if (isset($_POST['fullname']))
{
// process the data, see if it's valid.
// if it's valid and you're satisfied, do whatever you want with the
data
// (add it to a database or whatever), and then:
// header("Location: http://www.mysite.com/page2.php");
// (be sure not to output anything, including blank
// lines or spaces before the <?php
// before the call to header()
// if you're not satisfied with the data, start outputting the form
again
echo "<form name=....";
echo '<input type="text" name="fullname"
value="',htmlspecialchars($_POST['fullname']),'"><br>';
//....
}
else {
// display the form for the first time
echo "<form name=....";
echo '<input type="text" name="fullname"><br>';
}

?>
--- end of file ---

Jul 17 '05 #5

P: n/a
TG <tg********@cox.net> wrote:
Thanks for the inputs. No -- I'm not outputting anything before the header
and get no error messages. What is so confusing is that this was working
with the header redirect before. And yes I have seen logic similar to this
snippet you attached below.... I'll definitely use it in hopes it fixes this
problem!


It might be a good idea to post your relevant code, I have no idea what
you actually are doing in what way.

(and please keep the thread readable by editing the quotes in your
replies...).

--

Daniel Tryba

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.