I'm not sure if I actually have problem with checkbox form or age, height and weight which i put it in int as variable on phpMyAdmin. Because after I click signup, it just write error upside the form. So I really confuse where is my error
<?php
session_start();
if(isset($_SESSION['user'])!="")
{
header("Location: home.php");
}
include_once 'dbconnect.php';
if(isset($_POST['signup']))
{
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$upass = md5(mysql_real_escape_string($_POST['password']));
$age = $_POST['age'];
$disease=$_POST['disease'];
$weight = $_POST['weight'];
$heigth = $_POST['height'];
$dis="";
$flag=0;
foreach($disease as $entry){
$dis .= $entry."|";
$flag=1;
}
if($flag==1){
$dis=rtrim($dis);
}
// Insert data into mysql
$sql="INSERT INTO users(username,email,password, age, disease, weight, heigth) VALUES('$username','$email','$upass', '$age', '$dis', '$weight', '$heigth')";
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='P.SIGNUP.php'>Back to main page</a>";
}
else {
echo "ERROR"; }
}
?>
<form name=register method="post" class="form-horizontal" role="form" onSubmit="return validatePwd()">
<div class="form-group">
<div class="form-group">
<label for="disease" class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<h1>Register</h1>
</div>
</div>
<div class="form-group">
<label for="username" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="username" id="username" placeholder="User Name" class="required" />
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="password" name="password" placeholder="6-12 character" />
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Confirm Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" name="password2" placeholder="6-12 character" />
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">E-mail</label>
<div class="col-sm-10">
<input type="email" class="form-control" name="email" placeholder="Someone@example.com" class="email required" />
</div>
</div>
<div class="form-group">
<label for="age" class="col-sm-2 control-label">Age</label>
<div class="col-sm-10">
<input type="number" name="age" min="45" max="55" step="1" value="45" />
</div>
</div>
<div class="form-group">
<label for="disease" class="col-sm-2 control-label">Disease</label>
<div class="col-sm-10">
<input type="checkbox" name="disease[]" value="obesity" />Obesity<br/>
<input type="checkbox" name="disease[]" value="diabetes" />Diabetes<br/><br/>
<b>Cancer</b><br>
<input type="checkbox" name="disease[]" value="coloncancer" />Colon Cancer<br/>
<input type="checkbox" name="disease[]" value="kidneyCancer" />Kidney Cancer<br/>
<input type="checkbox" name="disease[]" value="breastCancer" />Breast Cancer<br/><br/>
<input type="checkbox" name="disease[]" value="cardio" />Cardio Disease<br/>
</div>
</div>
<div class="form-group">
<label for="weight" class="col-sm-2 control-label">Weight</label>
<div class="col-sm-10">
<input type="number" name="weight" min="30" max="180" step="10" />kg
</div>
</div>
<div class="form-group">
<label for="height" class="col-sm-2 control-label">Height</label>
<div class="col-sm-10">
<input type="number" name="height" min="100" max="200" step="10" />cm
</div>
</div>
</div>
<div class="form-group">
<label for="disease" class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<button type="submit" class="btn btn-primary" name="signup"> SIGNUP </button>
</div>
</div>
</form>
</div>