<?php
if (isset($_POST['submit']))
{
	$id2 = $_POST['credential_category'];
	
	$form =  '<form action="' . $_SERVER['PHP_SELF'] . '>"' . 'method="post">';
	$form .= '<p> Please Enter Your Credential</p><br/>';
	$form .= '<label>Credential:</label><br/>';
	$form .= '<input type="text"' . 'name="credential"' . 'size="40">' . '<br/><br/>';
	$form .= '<input name="submit2"' . 'type="submit"' . 'value="Submit" />';
	$form .= '</form>';
}

if (isset($_POST['submit2']))
{
	echo "Test";
}

?>
<body>
<p>Select a Credential Category:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

<select name="credential category">
	
    <option value="0" <?php if ($id2=='')
							echo 'selected="selected">';
						  ?>
                          
                           >---Select a Credential Category---</option>
<?php	
    //function to establish a database connection call db_connect()
$mysqli = new mysqli('localhost', 'root', 'Snaxster1', 'HHCL_TEST');

if (!mysqli)
{
	die('Connect Error (' . mysqli_connect_errno() . ')' . mysqli_connect_error() ); 
}


$query = 	"SELECT PKcredential_categoryID, credential_categoryName
			FROM credential_category";
			
if($result = $mysqli->query($query))
{
	while ($row = $result->fetch_assoc())
	{
		$id = $row['PKcredential_categoryID'];
		$name = $row['credential_categoryName'];
		echo '<option value = "' . $id . '"';
		
		if ($id==$id2)
			echo 'selected="selected"';
		
		echo  '>' . $name .  "</option>";
	}
	
	$result -> close();
}
$mysqli -> close();
?>   
</select>

<input name="submit" type="submit" value="Submit" />

</form>

<br/>

<?php

echo $form;
echo '<br/>';
echo $id2;
echo '<br/>';
echo $msg1;

?>
<br/>
<br/>

</body>
</html>

Not sure exactly what you need but I noticed you need to add spaces or your forms will be rendered wrong:

$form .= '<input type="text"' . 'name="credential"' . 'size="40">' . '<br/><br/>';
$form .= '<input name="submit2"' . 'type="submit"' . 'value="Submit" />';

Should be:

$form .= '<input type="text" ' . 'name="credential" '  . 'size="40" />' . '<br/><br/>';
$form .= '<input name="submit2" ' . 'type="submit" ' . 'value="Submit" />';

I don't really see why you would want to split them up like that in the first place.

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.