Notice: Undefined index: uname in E:\xampp\htdocs\test.php on line 4 . This error accourd
Data Base

CREATE DATABASE IF NOT EXISTS cms_project DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE cms_project;

-- --------------------------------------------------------

--

-- Table structure for table user_info

CREATE TABLE IF NOT EXISTS user_info (
id int(10) NOT NULL AUTO_INCREMENT,
uname varchar(10) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

<?php
mysql_connect("localhost","root","");
mysql_select_db("cms_project");
$username=mysql_real_escape_string($_POST['uname']);
$check=mysql_query("SELECT * FROM user_info WHERE uname='$username' ");
$check_rows= mysql_num_rows($check);
//echo $check_rows;
if($username==null)
    echo "Choose a username";
 else if(strlen($username)<=3)
    echo "Too Short";
 else
 {
    if($check_rows==0)
        echo "Available";
    else if($check_rows>=1)
        echo "Not Available";

 }
echo mysql_error();
?>
<html>
<head>
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
        $('#feedback').load('check.php').show();
        $('#username_input').keyup(function(){
            $.post('test.php', {username: form.username.value},
            function(result){
                $('#feedback') .html(result) .show();
            });
        });
    });
</script>
</head>
<body>
<div id="body">
        <h1 align="center">Signup</h1>
        <div id="logindiv">
        <table border="2" align="center">
            <form method="POST" action="test.php" name="form">
            <tr><th>Username</th><td><input type="text" id="username_input" name="uname" placeholder="User Name"  /></td></tr>
            <tr><th>Click</th><td><input type="submit" name="signup" value="Signup"/></td></tr>

            </form>
        </table>
        <div id="feedback"></div>
    </div>
</div>
</body>
</html>
Member Avatar for iamthwee

My guess would be:

The variable username: should really be uname: on line 29

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.