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> 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. 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. 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
Archived
This topic is now archived and is closed to further replies.