スクリプトに問題はありませんが、作成したデータベースにスクリプトが挿入されない理由がわかりません。親切に私のコードを見て、何が間違っているのかアドバイスしてください。これは、すべてのデータベース接続に使用される dbcon.php です。
<?php
$host="localhost";
$user="root";
$password="";
$db="cottonboard";
$tablename="user";
mysql_connect($host,$user,$password) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
?>
これは、入力をデータベースに挿入するスクリプトです。
<?php
include "dbcon.php";
extract($_POST);
/* just to test if all fields will be outputted
print_r($_POST);*/
$sql="INSERT INTO $tablename(id,username,password,accesslevel,sex,contactnmuber,employer)
VALUES('null','$usernameuser','$passworduser','$accesslevel','$gender','$contactnumberuser','$employeruser')" or die(mysql_error());
if($sql)
{
echo"we got here safe";
}
?>