JavaScript Session Management HTML Client and PHP on Server session management html,session management in html pages

Serverside: PHP Clientside: HTML and Javascript

I am trying to create a session manager in HTML (Phonegap). The HTML should maintain the session based on the authentication of PHP on server side.

I am able to start the session in PHP (its in the below code), what i need is, This session code of PHP should start within HTML.

I want the session of PHP in HTML because the phonegap does not understand PHP files. So i need to manage everything with HTML and javascripts.

HTML:

<input type="text" name="txt" id="txt" placeholder="Enter Your ID"   class="inputText"  />

<input type="submit" OnClick="JavaScript:doCallAjax();"  class="inputSubmit" value="Login">      

Javascript:
Script : var HttPRequest = false;

               function doCallAjax() {
                  HttPRequest = false;
                  if (window.XMLHttpRequest) { // Mozilla, Safari,...
                     HttPRequest = new XMLHttpRequest();
                     if (HttPRequest.overrideMimeType) {
                        HttPRequest.overrideMimeType('text/html');
                     }
                  } else if (window.ActiveXObject) { // IE
                     try {
                        HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
                     } catch (e) {
                        try {
                           HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch (e) {}
                     }
                  } 

                  if (!HttPRequest) {
                     alert('Cannot create XMLHTTP instance');
                     return false;
                  }

                  var url = 'http://localhost:9999/working-DONOT-TOUCH/login.php';
                  var pmeters = "tPassword=" + encodeURI( document.getElementById("txt").value );


                    HttPRequest.open('POST',url,true);

                    HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    HttPRequest.setRequestHeader("Content-length", pmeters.length);
                    HttPRequest.setRequestHeader("Connection", "close");
                    HttPRequest.send(pmeters);


                    HttPRequest.onreadystatechange = function()
                    {

                        if(HttPRequest.readyState == 3)  // Loading Request
                        {
                            document.getElementById("mySpan").innerHTML = "Now is Loading...";
                        }

                        if(HttPRequest.readyState == 4) // Return Request
                        {
                            if(HttPRequest.responseText == 'Y')
                            {
                                window.location = 'mainmenu.html';

                            }
                            else
                            {
                                alert('Wrong User ID    ');
                            }
                        }

                    }

               }
            </script>

PHP:

    session_start();


    $password = trim($_POST["tPassword"]);




    if(trim($password) == "")
    {
        echo "<font color=red>**</font> Plase enter [ID]";
        exit();
    }


    $mysqli=mysqli_connect('localhost','root','root','db');



$query = "SELECT * FROM pg_master_students_details WHERE  Stu_Register_No='$password'";
$result = mysqli_query($mysqli,$query)or die(mysqli_error());
$num_row = mysqli_num_rows($result);
        $row=mysqli_fetch_array($result);
    if($row)
    {
        echo "Y";


        $_SESSION["password"] = $password;
        session_write_close();
    }
    else
    {
        echo "<font color=red>**</font> ID is wrong";
    }

    mysqli_close($mysqli);
?>
Answer:1

I need to get rid of "↵" characters from the string, but I get some strange behavior from RegExp. Can someone explain this: var str = "↵Since we are starting our webservice..."; alert(str.charAt(0)) ...

I need to get rid of "↵" characters from the string, but I get some strange behavior from RegExp. Can someone explain this: var str = "↵Since we are starting our webservice..."; alert(str.charAt(0)) ...

  1. javascript regex test vs match
  2. javascript regex test example
  3. javascript regex test online
  4. javascript regex test string
  5. javascript regex test method
  6. javascript regex test case insensitive
  7. javascript regex test match
  8. javascript regex test not working
  9. javascript regex test for number
  10. javascript regex test doesn't work
  11. javascript regex test whole string
  12. javascript regex test always false
  13. javascript regex test alphanumeric only
  14. javascript regex test multiple strings
  15. javascript regex test ignore case
  16. javascript regex test exact match
  17. javascript regex test is not a function
  18. javascript regex test end of string
  19. javascript regex test fails
  20. javascript regex test variable

I write this html code : <div id="container"> <canvas id="imageView" width="1181" height="1181"> <p>Unfortunately, your browser is currently unsupported by our ...

I write this html code : <div id="container"> <canvas id="imageView" width="1181" height="1181"> <p>Unfortunately, your browser is currently unsupported by our ...

  1. click event canvas javascript
  2. click event canvas
  3. click event on canvas rectangle
  4. click event on canvas android
  5. click event on canvas element
  6. click event handler canvas
  7. html click event canvas
  8. get click event canvas
  9. canvas click event jquery
  10. add click event to canvas object
  11. canvas click event coordinates
  12. canvas click event wpf
  13. add click event to canvas
  14. canvas click event tkinter
  15. canvas click event not working
  16. canvas click event c#
  17. canvas click event location
  18. bind click event in canvas

I guess I'm used to using something like ant or maven that produces a war file and I deploy that war file to my server. With grunt I don't see what I'm supposed to deploy. Am I supposed to grab the ...

I guess I'm used to using something like ant or maven that produces a war file and I deploy that war file to my server. With grunt I don't see what I'm supposed to deploy. Am I supposed to grab the ...

  1. when was building with asbestos banned
  2. max iterations when building with cycles

I have found a short script which finds a line with a certain phrase in it and replaces the whole line with a new line. However I can't work out how to include a variable where it says '#RemoveMe' in ...

I have found a short script which finds a line with a certain phrase in it and replaces the whole line with a new line. However I can't work out how to include a variable where it says '#RemoveMe' in ...

  1. javascript replace with regex
  2. javascript replace with variable
  3. javascript replace with space
  4. javascript replace with new line
  5. javascript replace with nothing
  6. javascript replace with regular expression
  7. javascript replace with '
  8. javascript replace with line break
  9. javascript replace with wildcard
  10. javascript replace with group
  11. javascript replace with callback
  12. javascript replace with unicode
  13. javascript replace with match
  14. javascript replace with carriage return
  15. javascript replace with backslash
  16. javascript replace with double quotes
  17. javascript replace with empty string
  18. javascript replace with multiple strings
  19. javascript replace with escape character
  20. javascript replace with capture groups