JavaScript and PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RIGOLETO
Forum Commoner
Posts: 37
Joined: Fri Nov 20, 2009 10:13 am

JavaScript and PHP

Post by RIGOLETO »

Hi there,

Although this is a basic question, but for me is a big program, basically I need to get a variable from a JAVASCRIPT statement, this is the scenario.

I have written down a script to validate a Input screen, user, password and so for, well I am stoping my program every time the script found at least one blank field, but I need to execute a program to validate if the record added already exist in my MYSQL database, the problems is that I need to be sure that the previous step has been finished without any error, if so I will call my sql satement to check for a duplicated data, What I need?

I need to bring fron the script a kind of variable that could have True or Flase, if that variable is false then I will call my sql othewise i will keep validating for blanks

Problably I am worng with my logic,. so I really apreciate your coments

thanks in advance

Rigo
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: JavaScript and PHP

Post by JNettles »

Don't rely on Javascript when writing your PHP. While its all fine and nice and pretty to have Javascript validators you're just asking for trouble since you'll inevitably run into someone who has Javascript turned off. Perform your JS validations, then go ahead and redo them in PHP. It sounds redundant but its absolutely necessary.
RIGOLETO
Forum Commoner
Posts: 37
Joined: Fri Nov 20, 2009 10:13 am

Re: JavaScript and PHP

Post by RIGOLETO »

So you recomend do not use Javascript?

I willl try or redo my program to handle the whole of validation with PHP
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: JavaScript and PHP

Post by JNettles »

You can use Javascript on your web page - just don't rely on it to handle your validation.
harrymanjan
Forum Newbie
Posts: 2
Joined: Mon Dec 07, 2009 11:03 pm

Re: JavaScript and PHP

Post by harrymanjan »

Very true. But it might be easier to design your form validation on php first, then on javascript.

Ensure your server-side validation works, then client-side validation.

Else you have to turn off javascript to test php side validation when developing.
Post Reply