Two problems with id and sending text

Hello.

The first problem. I have a text form and a button.

html

<div style="position:relative; left:100px">
    <input type="text" id="poiskt">
    <input type="button" id="poiskb">
</div>

and

$("#poiskb").click(function () {
    var poiskt = $('#poiskt').val();
    alert(poiskt);
    $.ajax({
        url: "poisk.php",
        type: "POST",
        data: {
            poiskt: poiskt
        },
        success: function (data) {
            alert(data);
        }
    });
});

search.php

$findt = $_POST('poiskt');
$nickbd  = mysql_query("SELECT nick FROM registr WHERE nick='" . $_POST('poiskt') . "'");
$nickbdm = mysql_fetch_assoc($nickbd);
if (mysql_num_rows($nickbd) != 0)
    echo $nickbdm['nick'];
else
    echo 0;

alert(poiskt) outputs the text, and in poisk.php it writes the error “Function name must be a string”, although in this document I also passed another text and without any errors, in general I don’t know how to fix it, help, plz

And the second problem is

$("input.buttoncom").click(function () {
    var div = this.parentNode;
    var inptext = div.getElementsByTagName('*');
    var textcom = $(   ).val();
    alert(textcom);
});

The fact that inptext[0].idis the id of the text form from which I need to extract the text and I don’t know what to put in brackets, I tried like this

var textcom=$("#".inptext[0].id."").val();

but it didn’t work, plz tell me.

Thanks in advance.


Answer 1, authority 100%

1

$findt=$_POST['poiskt'];
$nickbd=mysql_query("SELECT nick FROM registr WHERE nick='".mysql_real_escape_string($findt)."'");
// ,  

2

inptext[0] – may still be empty text, but in general you just have the wrong approach

// var div=this.parentNode;
// var inptext=div.getElementsByTagName('*');
// var textcom=$(   ).val();
var textcom = $(this).parent().find('input:text').eq(0).val();
//    $(this).closest(':text').val()
alert(textcom);