Re: Values not displaying in second form after post.

From: Daniel Tryba (news_comp.lang.php_at_canopus.nl)
Date: 01/03/04


Date: Sat, 3 Jan 2004 03:54:55 +0000 (UTC)

TG <tgillette1@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


Relevant Pages

  • Re: Form validation with PHP/Javascript
    ... I don't rely on js for form validation. ... I validate everything server side. ... works beautifully, first the js, then the php. ...
    (comp.lang.php)
  • Re: [PHP] Validating Form input
    ... I like providing feedback on the validity of a form before the user leaves the page AND I hate duplicating the validation logic in Javascript when it's already present in my PHP. ... However, since there is no way to be sure the data sent to the server is actually valid, you have to check it in your php code on the server anyway. ...
    (php.general)
  • Re: Do you validate your forms with javascript or php?
    ... Javascript + PHP, or PHP alone. ... With Javascript you avoid involving the server, ... If you want to code validation only once, ...
    (comp.lang.php)
  • Re: Form Spam
    ... I'm weak on php, so I dropped in the code ... If you are lucky and the server validates the form then the code block ... thus the form submission will be rejected by the validation, ...
    (microsoft.public.frontpage.client)
  • Re: Attempt to de-mystify AJAX
    ... This lessens the chances that some bone-headed changes in browser behavior will affect things - I have much more confidence that PHP will maintain a sane, ... maximising the server side. ... address here for the sake of simplicity: validation. ... Javascript can work fairly well, but if you're writing it by hand, ...
    (comp.databases.pick)