I have created two text fields using HTML and I want to process that text into my database.
Using PHP I want to validate that data and also send it into the database; but my problem is that the data that I've entered in the fields are not processing into the database.
My code is as follows:
<form action="index.php" method="post">
<b>username:</b><input type="text" name="textbox1"/>
<b>password:</b><input type="password" name="textbox2"/>
<input type="submit" value="submit">
<?php
if(isset($_POST['textbox1'])&&isset($_POST['textbox2']))
{
$conn_error = 'couldnot connected';
$mysql_user = 'root';
$mysql_pass = '';
$mysql_host = 'localhost';
$mysql_db = 'yep_recharge';
$textbox1 = $_POST['textbox1'];
$textbox2 = $_POST['textbox2'];
if(empty($textbox1)&&empty($textbox2))
{
echo 'required field';
}
if(!empty($textbox1)&&!empty($textbox2))
{
$query = "SELECT `ID` FROM `yep_registration` WHERE `USERNAME`='$textbox1' AND `PASSWORD`='$textbox2'";//"SELECT `ID` from `yep_registration` WHERE `USER-NAME`='$textbox1' and `PASSWORD` = '$textbox2'";
if($query_run = mysql_query($query))
{
$query_num_rows = mysql_num_rows($query_run);
if($query_num_rows==0)
{
echo 'Invalid User Name And Password:';
}
else if($query_num_rows==1)
{
echo 'ok';
}
}
}
}
</form>