Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Please helpl this newbie

    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 .

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <?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.

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

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    This little Earth.
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if (document.LOGIN.username.value=="" || document.LOGIN.password.value=="")

    forgot the opening bracket of the 'if' condition in the code missing-score.
    'If you don't stand for something, you'll fall for anything.'

  • #5
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oops. Missed that. Cheers ASAAKI for pointing that out. Ill edit it now.

    P.S: Like your sig!

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    Registered User
    Join Date
    Apr 2003
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 .


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •