HAN! Posted October 24, 2007 Share Posted October 24, 2007 it just seem that the variables are not transferring from php into javascript, so can u take a look and see if i have somthing missing thank u; <?PHP $user='hani'; $pass='annd'; ?> <script language="JavaScript"> <!-- function validate(form) { var u=<?PHP echo '$user'; ?> var p=<?PHP echo '$pass'; ?> if (form.username.value!=u) ) { alert("Please enter the correct username"); form.username.focus(); return false; } if(form.password.value!=p) { alert("Please enter the correct password"); form.password.focus(); return false; } } //--> </script> </head> Quote Link to comment https://forums.phpfreaks.com/topic/74555-can-u-help-mw-with-that/ Share on other sites More sharing options...
GingerRobot Posted October 24, 2007 Share Posted October 24, 2007 Try: var u=<?PHP echo $user; ?> var p=<?PHP echo $pass; ?> You don't need the single quotes. Strings inside single quotes are treated as literals - what you were echoing would be the exact text $user - not the variable's value. Quote Link to comment https://forums.phpfreaks.com/topic/74555-can-u-help-mw-with-that/#findComment-376855 Share on other sites More sharing options...
rajivgonsalves Posted October 24, 2007 Share Posted October 24, 2007 var u="<?PHP echo $user; ?>"; var p="<?PHP echo $pass; ?>"; otherwise javascript would take the value of $user as a variable in javascript. Quote Link to comment https://forums.phpfreaks.com/topic/74555-can-u-help-mw-with-that/#findComment-376859 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.