473,386 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Values not displaying in second form after post.

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
5 4240
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TG | last post by:
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...
10
by: Joseph S. | last post by:
Hi, How do I pass a string from one call to a php block to another call in the same page but from another form? Here's my full php code: I'm using two forms in the same page. A hidden field...
3
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
7
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
6
by: Ian Davies | last post by:
Hi me again, sorry to be a pain. Ive been struggling with this one all day. Hope you can understand whats happening. First my script is below. Have a look and I'll explain at the bottom what it...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
7
by: cartercc | last post by:
I think I already know the answer to this one, but I'm giving it the old college try. My problem is this: I have an HTML form that sends a bunch of data to a Perl script, where it is validated...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.