I have a problem been a long. I am totally lost what is wrong! It does not give compile-time error. But it just doesnt add data to database.
register.php
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>My First Web site</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<? include("menu.php"); ?>
<div id="logo">
<h1><a href="#">Enter</a></h1>
<h2><a href="http://www.freecsstemplates.org/">By Free CSS Templates</a></h2>
</div>
<?
include("main_reg.php");
include("footer.php");
?>
<div align=center>This template downloaded form <a href='http://all-free-download.com/free-website-templates/'>free website templates</a></div></body>
</html>
main_reg.php
<div id="content">
<div id="colA">
<center>
<form action="user_reg.php" method="post">
<table width="531" border="0">
<tr>
<td width="212"><div align="right">username </div></td>
<td width="303"><input name="username" type="text" id="username" /></td>
</tr>
<tr>
<td width="212"><div align="right">password </div></td>
<td width="303"><input name="pass1" type="text" id="pass1" /></td>
</tr>
<tr>
<td width="212"><div align="right">password /confirmation/ </div></td>
<td width="303"><input name="pass2" type="text" id="pass2" /></td>
</tr>
<tr>
<td><div align="right">first name</div></td>
<td><input name="fname" type="text" id="fname" /></td>
</tr>
<tr>
<td><div align="right">lastname</div></td>
<td><input name="lname" type="text" id="lname" /></td>
</tr>
<tr>
<td><div align="right">age</div></td>
<td><input name="age" type="text" id="age" /></td>
</tr>
<tr>
<td><div align="right">sex</div></td>
<td><select name="sex" id="sex">
<option value="1">m</option>
<option value="2">f</option>
</select>
</td>
</tr>
<tr>
<td><div align="right">phone</div></td>
<td><input name="phone" type="text" id="phone" /></td>
</tr>
<tr>
<td><div align="right">Email</div></td>
<td><input name="email" type="text" id="email" /></td>
</tr>
<tr>
<td><div align="right">
<input type="reset" name="Reset" value="reset" />
</div></td>
<td>
<div align="center">
<input type="submit" name="Submit" value="register" />
</div></td>
</tr>
</table>
</form>
</center>
</div>
user_reg.php
<?
include("connect_db.php");
//$con=mysqli_connect("localhost", "root", "", "site");
//mysqli_query($con, "SET NAMES utf8");
$reg_query="insert into account values(Null,'" .$_POST['username'] . "', '" . $_POST['pass1']. "', '" .$_POST['fname'] ."', '" .$_POST['lname'] . "', " . $_POST['age'] .", " .$_POST['sex'] . ", '" . $_POST['phone'] . "', '" . $_POST['email'] ."')";
echo $reg_query;
//$reg_query="insert into account values(Null, '$_POST[username]', '$_POST[pass1]', '$_POST[fname]', '$_POST[lname]', '$_POST[age]', '$_POST[sex]', '$_POST[phone]', '$_POST[email]')";
$reg_result=mysqli_query($con, $reg_query);
if($reg_result!=0)
echo header("location: index.php");
else echo "failed! <a href='register.php'> back </a>"
?>
connect_db.php
<?
$con=mysqli_connect("localhost", "root", "", "site");
mysqli_query($con, "SET NAMES utf8");
?>