I have a problem about posting data to DB.When i reload the page,or go to the website,it sends null data to DB.Its because i haven't functioned the button(well,i mean an onclick event) for this.Directly wrote a php code under the form and it works if you fill the spaces such as text and textarea and click the button.Though,Im new to PHP,So what I exactly need is,learning how to function a button to insert data to database using PHP to prevent inserting data on every load of form.
Here is the code
<?php
$host="localhost";
$user="root";
$password="";
$db="mkappform";
$con=mysqli_connect("$host","$user","$password","$db");
if (! $con) die ("Unable to connect to database");
$name=$_POST["name"];
$nick=$_POST["nick"];
$pvnick=$_POST["pvnick"];
$age=$_POST["age"];
$country=$_POST["country"];
$timezone=$_POST["timezone"];
$servers=$_POST["servers"];
$checkban=$_POST["checkban"];
$contact=$_POST["contact"];
$history=$_POST["history"];
$reasons=$_POST["reasons"];
$whypastclans=$_POST["whypastclans"];
$anyotherinfo=$_POST["anyotherinfo"];
$query=mysqli_query($con,
"INSERT INTO mkappform(name,nick,pvnick,age,country,timezone,servers,checkban,contact,history,reasons,whypastclans,anyotherinfo)
values('$name','$nick','$pvnick','$age','$country','$timezone','$servers','$checkban','$contact','$history','$reasons','$whypastclans','$anyotherinfo')");
if($query == true)
echo "Application was sent successfully!!"
?>