I want to assign the value from database
HTML
<?php
$dbhost = 'localhost:3306';
$dbuser = 'root';
$dbpass = 'root';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db("test_db", $conn);
if(isset($_POST['submit']))
{
if(!empty($_FILES))
{
$allowedExts = array("gif", "jpeg", "jpg", "png","txt");
$temp = explode(".", $_FILES["resume"]["name"]);
$extension = end($temp);
if (($_FILES["resume"]["size"] < 50000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["resume"]["error"] > 0)
{
echo "Error: " . $_FILES["resume"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["resume"]["name"] . "<br>";
echo "Type: " . $_FILES["resume"]["type"] . "<br>";
echo "Size: " . ($_FILES["resume"]["size"] / 1024) . " kB<br>";
echo "Stored in: " . $_FILES["resume"]["tmp_name"];
}
}
else
{
echo "Invalid file
";
}
$name = $_POST['name'];
$age = $_POST['age'];
$quali = $_POST['quali'];
$state = $_POST['state'];
$country = $_POST['country'];
$msg = $_POST['msg'];
$resume = $_FILES["resume"]["name"];
$sql = "INSERT INTO form ".
"(name,age,quali,state,country,msg,resume) ".
"VALUES('$name','$age', '$quali', '$state','$country','$msg','$resume')";
mysql_select_db('test_db');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully
";
move_uploaded_file( $_FILES["resume"]["tmp_name"], "files/".$_FILES["resume"]["name"]);
}
mysql_close($conn);
}
?>
<div>
<form action="<?php $_PHP_SELF ?>" method="POST" enctype="multipart/form-data">
<div>Name:<input type="text" name="name" /></div>
<div style="height:10px"></div>
<div>Age:<input type="text" name="age" /></div>
<div style="height:10px"></div>
<div>Qualification:<input type="text" name="quali" /></div>
<div style="height:10px"></div>
<div>State:
<select name="state">
<option value="tn">TamilNadu</option>
<option value="kl">Kerala</option>
<option value="ka">Karnataka</option>
<option value="ani">Andhara</option>
</select>
</div>
<div style="height:10px"></div>
<div>Country:<input type="text" name="country" /></div>
<div style="height:10px"></div>
<div>Resume:<input type="file" name="resume" /></div>
<div style="height:10px"></div>
<div>Message:<textarea cols="10" rows="5" name="msg"></textarea></div>
<div style="height:10px"></div>
<div><input type="Submit" name="submit" value="Submit" /></div>
</form>
</div>
<div style="height:30px"></div>
<div>
<table class="table">
<tr>
<th>Name</th>
<th>Age</th>
<th>Qualification</th>
<th>State</th>
<th>Country</th>
<th>Resume</th>
<th>Message</th>
</tr>
<?php
$sql1 = "SELECT * FROM form";
$retval1 = mysql_query($sql1,$conn);
while($row = mysql_fetch_array($retval1))
{
$name_s = $row['name'];
$age_s = $row['age'];
$quali_s = $row['quali'];
$state_s = $row['state'];
$country_s = $row['country'];
$resume_s = $row['resume'];
$msg_s = $row['msg'];
?>
<tr>
<td><label name="name_s"><?php echo $name_s; ?></label></td>
<td><label name="age_s"><?php echo $age_s; ?></label></td>
<td><label name="quali_s"><?php echo $quali_s; ?></label></td>
<td><label name="state_s"><?php echo $state_s; ?></label></td>
<td><label name="country_s"><?php echo $country_s; ?></label></td>
<td><label name="resume_s"><?php echo $resume_s; ?></label></td>
<td><label name="msg_s"><?php echo $msg_s; ?></label></td>
</tr>
<?php
}
?>
</table>
</div>
when i submit the data, it is not shown in table and show error. after refreshing it shown correctly
It is my testing program only not for any application. tell me some suggestion. do i use ajax for that? or any other.