Coexistence php & javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rcb845@yahoo.fr

    Coexistence php & javascript

    Bonjour à tous,

    Je suis relativement nouveau dans ce monde. Actuellement, je construis
    des transactions d'administratio n d'une base de données avec PHP et
    MySql. J'ai installé sur mon poste local, easyphp 1.6, qui inclus
    apache, php et mysql.
    Jusque là pas de lézard.

    Dans une page .php, je vérifie l'existence de données et je veux
    signaler l'erreur en utilisant un "Window.ale rt" en javascript, comme
    ci-dessous :

    QUOTE
    echo "<span class='whitetit le'>shortname et fullname vide" . " " .
    $_POST ["newcatartshort name"] . "</span><br>" ;
    ?>
    <span class='whitetit le'>je suis ici<br></span>
    <script language="JavaS cript" type="text/javascript">
    window.alert("V euillez saisir toutes les informations ...");
    document.locati on.href='contro lpanel.php?m=2& s=add';
    </script>
    <?php
    echo "<span class='whitetit le'>debug 100 fin erreur<br></span>" ;
    UNQUOTE

    L'erreur est la suivante :
    - le window.alert ne s'affiche pas et un signal sonore est émis par le
    PC.
    - Il n'y a pas d'erreur javascript dans le barre en bas à gauche.

    Sur le même PC, j'exécute des pages .html avec des javascript
    identiques qui s'exécutent correctement. J'arrive à croire qu'il y a
    un problème de configuration à quelque part soit dans apache ou php.

    Quelqu'un a-t-il eu un problème semblable ? Merci de renseigner.

    D'avance merci de votre aide

    RCB 845
  • Geoff Berrow

    #2
    Re: Coexistence php &amp; javascript

    I noticed that Message-ID:
    <18b577b2.04061 72358.647c592a@ posting.google. com> from rcb845@yahoo.fr
    contained the following:
    [color=blue]
    ><script language="JavaS cript" type="text/javascript">
    >window.alert(" Veuillez saisir toutes les informations ...");
    >document.locat ion.href='contr olpanel.php?m=2 &s=add';
    ></script>[/color]


    Why not use PHP to do the verification instead?
    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Michael Austin

      #3
      Re: Coexistence php &amp; javascript

      Geoff Berrow wrote:
      [color=blue]
      > I noticed that Message-ID:
      > <18b577b2.04061 72358.647c592a@ posting.google. com> from rcb845@yahoo.fr
      > contained the following:
      >
      >[color=green]
      >><script language="JavaS cript" type="text/javascript">
      >>window.alert( "Veuillez saisir toutes les informations ...");
      >>document.loca tion.href='cont rolpanel.php?m= 2&s=add';
      >></script>[/color]
      >
      >
      >
      > Why not use PHP to do the verification instead?[/color]


      One of the benefits of Javascript is that this can be executed prior to
      submission - reduces bandwidth and server hits. I try to put as much
      form verification on the front end as possible, but if your users are
      primarily geeks who generally have javascript turned off, then your only
      method is to have PHP do it for you -- preferably at the start of your
      next page code...

      I have used both methods, so YMMV.

      Michael.

      Comment

      • Gordon Burditt

        #4
        Re: Coexistence php &amp; javascript

        >> Why not use PHP to do the verification instead?[color=blue]
        >
        >
        >One of the benefits of Javascript is that this can be executed prior to
        >submission - reduces bandwidth and server hits. I try to put as much[/color]

        One of the benefits of doing data input validation with PHP is that
        one of your users can't trivially bypass it. This is not true of
        Javascript. If the input validation is for security or data integrity
        reasons, DO NOT trust Javascript to do it for you. It's easily
        turned off. Or someone could save your page and edit out the checks.
        If you want user-friendliness AND security, make the check in BOTH
        places.
        [color=blue]
        >form verification on the front end as possible, but if your users are
        >primarily geeks who generally have javascript turned off, then your only
        >method is to have PHP do it for you -- preferably at the start of your
        >next page code...
        >
        >I have used both methods, so YMMV.[/color]

        Hopefully both on the same submit button click.

        Gordon L. Burditt

        Comment

        • rcb845@yahoo.fr

          #5
          Re: Coexistence php &amp; javascript

          OK, I must thank all of you to have replied to my message.
          Of course, I could do the verification prior invoking the job on the
          server.
          I think I shall investigate this way of doing things^, to solve my
          problem.

          It is a way of doing things, it DOES NOT answer the basic question why
          my javascript doesnt work, when called from a php page.

          I tried my coding on another machine, also on local using easyphp and
          it does work, so I suspect to have some parameter on my machine which
          interfere with that. I shall have a real deep look on this side.

          On the meantime, thanks again for your help.

          Best regards

          RCB 845

          Comment

          Working...