0

hello...

i am doing login verification. there is tabs in index page thats why i am choosen this. actually after entering the values of email and password how to check that values are in database or not using javascript. and i will show message in alert box.
this is my script.

<script type="text/javascript">
function manage_validate()
{
if(window.document.manageaccount.managajob.value=='Employer')
{

<? 
$emp_select=mysql_query("select * from employer_registration where email='"+email+"' && password='"+password+"' && status=1");
$emp_num=mysql_num_rows($emp_select);
if($emp_num<=0)
{
?>
alert("You Are Entered Wrong Details");
window.document.manageaccount.email.select();
return false;
<?
}
?>

}
if(window.document.manageaccount.managajob.value=='Work seeker')
{
<?
$ws_select=mysql_query("select * from workseeker_registration where email='"+email+"' && password='"+password+"' && status=1");
$ws_num=mysql_num_rows($ws_select);
if($ws_num<=0)
{
?>
alert("You Are Entered Wrong Details");
window.document.manageaccount.email.select();
return false;
<?
}
?>
}

else return true;
}
</<script>
2
Contributors
5
Replies
8
Views
7 Years
Discussion Span
Last Post by saiprem
0

hmmm, You said , you don't require javascript, but still you are using javascript in your php :).

My suggestion is put the login details in a session(email, username , password....whatever you need), onClicking each tab call the check function, If it fails echo an error in alert box, and redirect him to enter correct details, else give him access to view the tab content

Hope I think it helps you

Edited by saiprem: n/a

0

hmmm, You said , you don't require javascript, but still you are using javascript in your php :).

My suggestion is put the login details in a session(email, username , password....whatever you need), onClicking each tab call the check function, If it fails echo an error in alert box, and redirect him to enter correct details, else give him access to view the tab content

Hope I think it helps you

hmmmm....sorry i didnot understood. if you dont mind how to use javascrit variables in php mysql query. is there any chance to workout like this. why because i have to change entire pages to implement the process which you said ....thats why ...

0

We can not use javascript variables in PHP scripts with out submitting the form.

With out submitting the form, you can not take the values of the form to check in PHP script.

The reason is that while loading the page, javascript will be executed first, after that PHP script will be executed.


hmmmm....sorry i didnot understood. if you dont mind how to use javascrit variables in php mysql query. is there any chance to workout like this. why because i have to change entire pages to implement the process which you said ....thats why ...

0

We can not use javascript variables in PHP scripts with out submitting the form.

With out submitting the form, you can not take the values of the form to check in PHP script.

The reason is that while loading the page, javascript will be executed first, after that PHP script will be executed.

before this step i write like this . this is working with out post. check it once like this . is there any chance like this? tell me please..

<script>
email=window.document.create_profile.email.value;
var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;
if(email== "")
{   
    alert("Please enter Email Id.");
    window.document.create_profile.email.focus();
    return false;

}

if(email!= "")
{   
    var eres=email.search(emailFormat);
    if(eres == -1)
    {
        alert("Please Enter Valid Email Id ");
        window.document.create_profile.email.select();
        return false;
    }
    else
    {

    <?
    $selectemail=mysql_query("select email from workseeker_registration");
    while($fetchemail=mysql_fetch_array($selectemail))
    {

    ?>
    if(email=='<?=$fetchemail[0];?>')
    {
    alert("This email already exists");
        window.document.create_profile.email.select();
        return false;
        }
    <?
    }
    ?>
    }

}
</script>

Edited by mike_2000_17: Fixed formatting

0

I am really surprising that how the code is working, As I already told you that javascript will works only in Client side operations. But after seeing your code , i have a great surprise today.

Because javascript will not hit the server while checking the validations, the only solution I know that you need to make an Ajax call to check the textbox's data onBlur.

before this step i write like this . this is working with out post. check it once like this . is there any chance like this? tell me please..

<script>
email=window.document.create_profile.email.value;
var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;
if(email== "")
{   
    alert("Please enter Email Id.");
    window.document.create_profile.email.focus();
    return false;

}

if(email!= "")
{   
    var eres=email.search(emailFormat);
    if(eres == -1)
    {
        alert("Please Enter Valid Email Id ");
        window.document.create_profile.email.select();
        return false;
    }
    else
    {

    <?
    $selectemail=mysql_query("select email from workseeker_registration");
    while($fetchemail=mysql_fetch_array($selectemail))
    {

    ?>
    if(email=='<?=$fetchemail[0];?>')
    {
    alert("This email already exists");
        window.document.create_profile.email.select();
        return false;
        }
    <?
    }
    ?>
    }

}
</script>

end quote.

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.