...

View Full Version : Please helpl this newbie



bahy
04-07-2003, 09:22 PM
Can anyone help me to mix my project with php (session hadling ) and javescript ?
All i wanna do is making my visitors to enter their username and pass word - using session , and the javascript code is used for checking if the entered username and pass word is null , if null then do the alert . My code is like this

<?
session_start();
?>
<script language = "javascript">
function Validate()
{
if document.LOGIN.username.value="" || document.LOGIN.password.value="")
{
alert("You should enter username and password to login !");
}
</script>
<?
.....
........

<form method=post action = login.php name=LOGIN onSubmit = return Validate() >
...........
...........

</form>
..........
?>
The first problem is on the top of the page there is a scentence "Warning: open(/tmp\sess_0ccee9d6f5ad6c764fcd7fd1682c3496, O_RDWR) failed: m (2) in d:\fox\www\login.php on line 2) . How can i solve this .
and the next problem is that when i don't type a word in username and password and click on submit button , it goes to the login succeful page (it did not alert ) . Where does it go wrong ?
Waiting for your help .

missing-score
04-07-2003, 09:35 PM
<?php
session_start();
?>
<html>
<head>
<script type="text/javascript">
<!--
function Validate()
{
if(document.LOGIN.username.value=="" || document.LOGIN.password.value=="")
{
alert('NO CHANCE!');
}
else
{
document.LOGIN.submit();
}
}
//-->
</script>
</head>
<body>

<form name="LOGIN" .......
........

<input type="button" value="Login" onClick="Validate()" />
</form>
</body>
</html>


Firstly, to see if something is equal to something else in javascript, you need to use 2 equals signs.

if(document.LOGIN.username.value == '')

And you dont need to put return Validate() on the form.

You could just check it with PHP. If you need any more help, just post back. :thumbsup:

Remember, session_start() must go before the <html> tag, or any other tags for that matter

Nightfire
04-07-2003, 09:52 PM
The first problem is on the top of the page there is a scentence "Warning: open(/tmp\sess_0ccee9d6f5ad6c764fcd7fd1682c3496, O_RDWR) failed: m (2) in d:\fox\www\login.php on line

You need to create a directory called tmp, to find out exactly where it should go, look in your php.ini file

ASAAKI
04-07-2003, 09:53 PM
if (document.LOGIN.username.value=="" || document.LOGIN.password.value=="")

forgot the opening bracket of the 'if' condition in the code missing-score.

missing-score
04-07-2003, 10:09 PM
Oops. Missed that. Cheers ASAAKI for pointing that out. Ill edit it now.

P.S: Like your sig!

Spookster
04-07-2003, 10:14 PM
bah, please read the forum posting guidelines before creating anymore threads:

http://www.codingforums.com/postguide.htm

"Please helpl this newbie" is not a proper subject for threads.

bahy
04-08-2003, 12:24 PM
Thanks all for joining this thread .
with Php.ini i can found a line with this content : session.save_path = /tmp .
So the directoty /tmp must be made , but where do i make it ,the problem is where is its parent directory , My php.ini is in d:\Windows , my Apache server is D:\fox\server\Apache . both have the dir /tmp . So next where do i have to make this dir ?

Help me plz , it is urgent .



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum