Click here to Skip to main content
15,895,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was expecting an ouput but it didn't show any. Is there missing in my code or what's wrong? Thanks in advance

I have this line of code in my main page

XML
<form>
        <label for="text_email">E-mail:</label>
        <input id="text_email" type="email" >

        <script type="text/javascript" charset="utf-8" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js">
            $(document).ready(function(){
                $('#text_email').keyup(function(){
                    email($(this).val());
                });
            });
            function email(str){
                $.post('checkmail.php',{ email: str},
                function(data){
                    $('#check_email').html(data.returnValue);
                }, 'json');
            }
        </script>

        <label for="text_email" id="check_email"></label>
    </form>


And this line of code

PHP
<?php
if(isset($_POST['email']))
{
    try
    {
        $pdo=new PDO('mysql:host=localhost;dbname=class;charset=utf-8', 'root');
    }
    catch(PDOException $e)
    {
        echo 'Failed: '.$e->getMessage();
    }

    $stmt=$pdo->prepare('SELECT email FROM class where email=:email LIMIT 1');
    $stmt->execute(array(':email'=>$_POST['email']));
    if($stmt->rowCount()>0)
    {
        $check='E-mail cannot be use.';
    }
    else
    {
        $check='E-mail can be use.';
    }

    echo json_encode(array('returnValue'=>$check));
}
?>
Posted
Comments
ZurdoDev 27-Aug-12 15:24pm    
So, what specific line of code is giving you a problem?
Mohibur Rashid 29-Aug-12 1:41am    
first pointer: your src in script tag is wrong. it should be src="http//:ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900