user6779766 user6779766 - 2 months ago 8
Javascript Question

How to run a javascript in login session?

I have login session which works fine.. i thought of adding some fade effect to it when username is true, but unfortunately its not working..

My code as follows::

<?php

include 'answer.php';
//15 2 2015
session_start();
$Cser = mysqli_connect("localhost","root","madhavi3693","the_database") or die("Server connection failed : ".mysqli_error($Cser));
$id = $_REQUEST["id"];
$username = $_REQUEST["username"];

$s = "select * from enjoin where username='".$username."'";

$result = mysqli_query($Cser,$s);

$count = mysqli_num_rows($result);

if($count>0)
{
$_SESSION["login"]="1";
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".login").click(function(){
$(".showup").fadeOut()
$(".showup2").fadeOut()
$('form#form2').fadeOut()
});
});
</script>

<?php
}
else
{
header("location:answer.php?err=1");
}
?>


any help is appreciated..

Answer

try this

UPDATE 2:

as per your comment you need to fade out the form when user is valid just remove that click action its work as you expected

        if($count>0)
    {
        $_SESSION["login"]="1";
    ?>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <script>
        $(document).ready(function(){

        $(".showup").fadeOut()
        $(".showup2").fadeOut()
        $('form#form2').fadeOut()

    });
    </script>

    <?php
    }
    else
    {
        header("location:answer.php?err=1");
    }

UPDATE 1:

$(document).ready(function(){
       $(".login").click(function(){
          
         // alert("hiii");
    $(".showup").fadeOut();
    $(".showup2").fadeOut();
    $('form#form2').fadeOut();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


<input type="button" class="login" value="click"  />
<p class="showup">sdfffffffffffffffff</p>
<p class="showup2">sdfffffffffffffffff</p>
<p class="showup">sdfffffffffffffffff</p>

Comments