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

Coexistence php & javascript

P: n/a
Bonjour à tous,

Je suis relativement nouveau dans ce monde. Actuellement, je construis
des transactions d'administration 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.alert" en javascript, comme
ci-dessous :

QUOTE
echo "<span class='whitetitle'>shortname et fullname vide" . " " .
$_POST ["newcatartshortname"] . "</span><br>" ;
?>
<span class='whitetitle'>je suis ici<br></span>
<script language="JavaScript" type="text/javascript">
window.alert("Veuillez saisir toutes les informations ...");
document.location.href='controlpanel.php?m=2&s=add ';
</script>
<?php
echo "<span class='whitetitle'>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
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I noticed that Message-ID:
<18**************************@posting.google.com > from rc****@yahoo.fr
contained the following:
<script language="JavaScript" type="text/javascript">
window.alert("Veuillez saisir toutes les informations ...");
document.location.href='controlpanel.php?m=2&s=ad d';
</script>

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/
Jul 17 '05 #2

P: n/a
Geoff Berrow wrote:
I noticed that Message-ID:
<18**************************@posting.google.com > from rc****@yahoo.fr
contained the following:

<script language="JavaScript" type="text/javascript">
window.alert("Veuillez saisir toutes les informations ...");
document.location.href='controlpanel.php?m=2&s=a dd';
</script>


Why not use PHP to do the verification instead?

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.
Jul 17 '05 #3

P: n/a
>> Why not use PHP to do the verification instead?


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
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.
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.


Hopefully both on the same submit button click.

Gordon L. Burditt
Jul 17 '05 #4

P: n/a
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
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.