hello guys i am stuck in a small but horrible problem.i am redirect page to itself using $_server[''PHH_SELF]
method but the problem is that i apply the insert query at the top of my html page but it shows me that you are not connect to the DB.
<?php
if(isset($_POST['action']))
{
$con = mysql_connect("localhost","root","");
if ($con)
{
die('connected: ' );
}
else{
echo "not connected"; [B][U]// ITS ECHO ME NOT CONNECT WHAT THE PROBLEM I CANT FIGURE IT OUT[/U][/B]
}
$db_selected = mysql_select_db("project", $con);
echo $classess = $_POST['class_name'];
$sql = mysql_query("INSERT INTO `classes` (class_name) VALUES ('$classess')");
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="enter_classCss.css" />
<?php include("header.php"); ?>
</head>
<div class="upper">
</div>
<div class="main">
<div class="center">
<div class="testing">
</div>
<div class="test">
</div>
</div>
<div class="white">
<div class="wrapper2" style="float: left;margin-left: 6px;margin-top: -35px;">
</div>
<form id="formID" class="formular" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" style="width:600px">
<div class="field2">
<span>Enter Class</span>
</div>
<div class="newfield">
<span>Class</span>
</div>
<div class="field5">
<input type="text" class="validate[required] text-input" name="class_name" id="class_name" />
</div>
<input type="submit" value="submit" style=" margin-left: -90px;
margin-top: 234px;"/> </div>
</form>
</div>
<div class="image">
<img src="images/compclass.jpg" style=" width:40px; height:40px;"/>
</div>
<div class="name2">
Class Form
</div>
</body>
</html>