The file is called test.php, It takes username and check if it is blank in the same page and show a message.. I wrote the code but its not working.. please help.
test.php:
<html>
<form method="post" action="test.php">
User Name :
<input name="UserName" type="text" id="UserName" value="User Name" size="20" maxlength="30" />
<input type=submit value=Submit>
</form>
</html>
<?php
mysql_connect("Localhost","username","password")
or die("Failure to communicate");
mysql_select_db("mydb")
or die("Could not connect to Database");
if($_POST == 'Submit'){
if(!$_POST) || $_POST==""){
echo "Enter User Name";}}
else{
$p="INSERT INTO mytable(UserName)VALUES('$UserName')";
$q=mysql_query($p);}
?>