473,657 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 17 '05 #1
4 1930
I noticed that Message-ID:
<18************ **************@ posting.google. com> from rc****@yahoo.fr
contained the following:
<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>

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
Geoff Berrow wrote:
I noticed that Message-ID:
<18************ **************@ posting.google. com> from rc****@yahoo.fr
contained the following:

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


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

Similar topics

4
3017
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: /mypage.asp?value1=1&amp;value2=4&amp; ... which of course means nothing to asp.
4
3217
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know that I could externalize my JavaScript, but that will not be practical throughout this application. Is there any way to get around this issue? Xalan processor. Stripped down stylesheet below along with XHTML output. <?xml version='1.0'?>...
3
1349
by: Nathan Sokalski | last post by:
I have a VB.NET function that I am using in an ASP.NET page. The code creates a String, which contains && (the JavaScript Logical AND operator) and is used as part of the JavaScript sent to the browser. However, ASP.NET is converting this to &amp; even though it is intended to be part of the JavaScript. This is causing my JavaScript not to work correctly. How can I prevent ASP.NET from doing this substitution? Thanks. -- Nathan Sokalski...
8
2802
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
14
5923
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only because of this, so I hope some of you gurus can enlighten me with this :) In what circumstances can the "&amp;" in the source code be involuntary changed to "&" by a browser when or other software, when editing and uploading the file to the web...
12
10095
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b) ..... // xsl contents abc.aspx?p1=v1&amp;p2=<xsl:value-of select="$v2" />
3
3228
by: Nathan Sokalski | last post by:
I am adding an onmouseover attribute using the Attributes.Add() method, and the String I am using for the value contains the & character. However, when rendered the & is converted to the HTML representation of &amp; which causes my JavaScript not to work. What can I do to prevent the Add() method from modifying my value? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
0
8324
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.