FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Javascript - Unexpected results





deathseaker
I have a site, working on a PHP login / registration system so i downloaded this HUGE validation script and embeded it into my project, the script has about 3 .js files. However when i do in the html <script language="javascript" src="blah/blah/somefile.js"></script> it wont work.

Thats because on the index.php i have it start a session and if it knows its not logged in i make index.php include login.htm into it to make it look like its part of index.php. so its not injecting the source into the file.

---------------------------------------
For now i jsut do

Code:

<!-- html above and below (in header section at momment)
-->
<head>
<title>Some title</title>
<script language="javascript">
<?php require_once('blah/blah/somefile.js'); ?>
</script>
</head>


Is there anyway that i can get this to work WITHOUT having to inject the contents of the file into the index.php file?

I ask of this because first of the source for the page wont be like a 30 page print if you got to print it and the somefile.js file if you point your broswer to it it wont show it because it has:

Code:

<!--
//javascript code..

//-->


which makes the hwole thing a comment in html meaning they wont see anything unless they view the source of the page (a way for me to hide the stuff as much as possible Razz)
jabapyth
when you say "it wont work" does that mean the js file doesn't load? (you can check it using firebug). If that's the case, you probably have the "blah/blah/somefile.js" wrong. try telling it to work from the root directory, as opposed to relative, eg.:

your php script is at "/blah/foo/bar.php"
your js is at "/blah/foo/foobar/blah.js"

put "/blah/foo/foobar/blah.js" instead of "foobar/blah.js" in the "src" parameter
Fire Boar
Why are you using such a massive script in the first place? You can achieve the same thing with about 10 kb of PHP script, and no javascript. I'd avoid javascript if I were you because some people have javascript turned off in their browsers.
deathseaker
lol i tried everything this is how it originally was:

Tree:
|
|
-- index.php
|
-- DIR: html
..|
..-- DIR: default
....|
....| -- html/default/login.htm
....| -- html/default/register.htm
....|
..-- DIR: --js
....| -- html/--js/val.js
....| -- html/--js/fx.js
....| -- html/--js/obj.js

[ignore .'s they r jsut spacers]

i tried both:
Code:
<script src="html/--js/val.js" language="javascript"></script>

--AND--
Code:
<script src="../--js/val.js" language="javascript"></script>


And i knew the second worked becasue when i loaded up the login.htm file on my PC it worked but when i included the login.htm file into the index.php on the site it wouldn't work..
flatliner
As fire boar has suggected above use a PHP & MySQL , nice and easy. Your members register and there details are placed in a MySQL database and then when they are going to log in this information is pulled from the database and check against what the user input. easy.
Related topics
Dreamweaver
Ie.why do people use it..anyway, because I have to use it...
Hockey WC 2006
A C program in Linux
A C program in Linux
C program with 3D array, in Linux
Windows XP SP3 comming soon
CSS: Reference Div inside a Div
PHP and cookies. Simple problem.
Corel Draw vs Adobe Illustrator
AI
centering links in ul li
Power of exploration and discovery
The End of the World is Nigh
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.