| re: Values not displaying in second form after post.
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" <ifetteNOSPAM@comcast.net> wrote in message
news:bt5j0g$3ih3h$1@ID-30799.news.uni-berlin.de...[color=blue]
> TG wrote:[color=green]
> > 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.[/color]
>
> That's fine...
>[color=green]
> > 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.[/color]
>
> The php page that processes the values does not have to be a separate[/color]
page,[color=blue]
> and the users do not have to be redirected to an error page. It is[/color]
entirely[color=blue]
> possible to keep the user at the same page...
>[color=green]
> > 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.[/color]
>
> 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.
>[color=green]
> > 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![/color]
>
> 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 ---
>
>[/color] |