<?php
require_once('upper.php');
require_once('database.php');
echo $error_msg='';
if(isset($_POST['submit']))
{
$LoginId=mysqli_real_escape_string($dbc,trim($_POST['LoginId']));
$Password1=mysqli_real_escape_string($dbc,trim($_POST['Password1']));
$Password2=mysqli_real_escape_string($dbc,trim($_POST['Password2']));
$Name=mysqli_real_escape_string($dbc,trim($_POST['Name']));
$Age=mysqli_real_escape_string($dbc,trim($_POST['Age']));
$BloodGroup=mysqli_real_escape_string($dbc,trim($_POST['BloodGroup']));
if(!isset($_POST['Sex']))
{
echo 'Please enter Sex<br>';
}
else{
$Sex= mysqli_real_escape_string($dbc,trim($_POST['Sex']));
}
$Qualification=mysqli_real_escape_string($dbc,trim($_POST['Qualification']));
$ContactNumber=mysqli_real_escape_string($dbc,trim($_POST['ContactNumber']));
$Email=mysqli_real_escape_string($dbc,trim($_POST['Email']));
$Address=mysqli_real_escape_string($dbc,trim($_POST['Address']));
$AboutYourself=mysqli_real_escape_string($dbc,trim($_POST['AboutYourself']));
//$countCheck=count($_POST['checkbox']);
//echo $countCheck;
//$checkbox=$_POST['checkbox'];
//$countCheck=count($checkbox);
	if(empty($LoginId)){echo 'Please enter Login Id';}
	elseif(empty($Password1)){echo 'Please enter Password';}
	elseif(empty($Password2)){echo 'Please confirm Password';}
	elseif($Password1!==$Password2){echo 'Password didn\'t match';}
		elseif(empty($Name)){echo 'Please enter Name';}
		elseif(empty($Age)){echo 'Please enter Age';}
		elseif(!isset($_POST['Sex'])){}
		elseif(empty($Qualification)){echo 'Please enter Qualification';}
		elseif(empty($ContactNumber)){echo 'Please enter Contact Number';}
		elseif(empty($Email)){echo 'Please enter Email';}
		elseif(empty($Address)){echo 'Please enter Address';}
		elseif(empty($AboutYourself)){echo 'Please enter About Yourself';}
		elseif(!isset($_POST['checkbox'])){ echo 'You have to register at least one activity.';}
		else
		{
		require_once('database.php');
		$query="select * from registration where LoginId='$LoginId'";
		$result=mysqli_query($dbc,$query);
		if(mysqli_num_rows($result)==0)	
		{		
		$checkbox=$_POST['checkbox'];
		$countCheck=count($_POST['checkbox']);
		$reg_id=' ';
		for($i=0;$i<$countCheck;$i++)
		{
		$reg_id=$reg_id.$checkbox[$i].',';
		}
		$query="insert into registration (LoginId,Password,Name,Age,BloodGroup,Sex,Qualification,ContactNumber,Email,Address,AboutYourself,Activity)values ('$LoginId',SHA('$Password1'),'$Name','$Age','$BloodGroup','$Sex','$Qualification','$ContactNumber','$Email','$Address','$AboutYourself',',$reg_id')";
		$result=mysqli_query($dbc,$query) or die("Not Connect");
		
		echo ' Dear '.$Name.'.<br>Your Account is waiting for approval<br>';

		//header('Location: index.php');
		//	header('Location: Registration.php');
		}
		else
		{
		echo 'Dear '.$Name. ', <br> An account already exist with login-id<b> '.$LoginId.'</b> <br>Please try another login-id';
		}}	
}		
?>

<html>


<body>

<?php
echo $error_msg; ?>

<form action='<?php echo $_SERVER['PHP_SELF'];?>' method='post'>
<div class="registration_and_activity">

<table border="0" width="400">
<tr><td colspan="2">
<h3>New User?</h3></td></tr>
<tr><td width="120">
Enter Login id</td><td><input type='text' name='LoginId' value='<?php if(!empty($LoginId))echo $LoginId;?>' /></td></tr>
<tr><td>
Enter Password</td><td><input type='password' name='Password1' value='<?php if(!empty($Password1))echo $Password1;?>' /></td></tr>
<tr><td>
Confirm Password</td><td><input type='password' name='Password2' value='<?php if(!empty($Password2))echo $Password2;?>' /></td></tr>
<tr><td>
Enter Name</td> <td><input type='text' name='Name' value='<?php if(!empty($Name))echo $Name;?>' /></td></tr>
<tr><td>
Enter Age</td><HEAD>
   <SCRIPT language=Javascript>
      
      function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
	  
	  
     
   </SCRIPT>
   </HEAD>
<td><INPUT onkeypress='return isNumberKey(event)' type='text' name='Age' value='<?php if(!empty($Age))echo $Age;?>'/></td></tr>

<tr><td>
Enter Blood</td><td><input type='text' name='BloodGroup'value='<?php if(!empty($BloodGroup))echo $BloodGroup;?>' /></td></tr>

<tr><td>
Enter Sex</td><td><input type='radio' name='Sex' style='width:16px; border:0;' 'value='Male' />Male   <input type='radio' name='Sex' style='width:16px; border:0;' 'value='Female' />Female</td></tr>

<tr><td>
Enter Qualification</td><td><input type='text' name='Qualification' value='<?php if(!empty($Qualification))echo $Qualification;?>' /></td></tr>

<tr><td>
Enter Contact Number </td><td><input onkeypress='return isNumberKey(event)'type='text' name='ContactNumber' value='<?php if(!empty($ContactNumber))echo $ContactNumber;?>' /></td></tr>

<tr><td>
Enter Email</td><td><input type='text' name='Email' value='<?php if(!empty($Email))echo $Email;?>' /></td></tr>

<tr><td>
Enter Address</td><td><input type='text' name='Address' value='<?php if(!empty($Address))echo $Address;?>' /></td></tr>


<tr><td>
About Yourself :</td></tr>
<tr><td colspan="2"><textarea rows='10' cols='40' name='AboutYourself' value='<?php if(!empty($AboutYourself))echo $AboutYourself;?>' /></textarea></td></tr>
<tr><td>

<?php echo"
<tr><td colspan='2'><b>Select fields for which you want to register</b></td></tr>";

require_once('database.php');
$query="select * from activity";
$result=mysqli_query($dbc,$query);
while($row=mysqli_fetch_array($result)){
$Title=$row['Title'];
$ActivityId=$row['ActivityId'];
echo "<tr><td>$Title</td>";
//echo $ActivityId;
echo "<td><input type='checkbox' name='checkbox[]' value=$Title style='width:14px; text-align:right;'/></td></tr>";//value=$ActivityId tells ActivityId variable extracts with name="checkbox"
echo "<br/>";
}
echo "<tr><td colspan='2' align='center'><input type='submit' value='Register' name='submit' style='background:url(./images/button_img2.png) no-repeat 10px 0px; width:100px; padding:3px 0 10px 0; color:#FEFBC4; border:0;'/></td></tr><br>";
	
echo " </td></tr></table>

</div>

</form>
</body>
</html>";
require_once('lower.php');
?>

In above code when $Title="Fire" or any single word, it inserts in database properly but when $Title="Terrist Attack" or any data more than one word it inserts only the first word "Terrist".
I want to insert the whole "Terrist Attack " as it is in database.........
What i should do??????????/
Plzzzzzzzzzzz help Anyone????????????

This happens probably because your forgot the quotes. I think it should be:

echo "<td><input type='checkbox' name='checkbox[]' value='$Title' style='width:14px; text-align:right;'/></td></tr>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.