<?php
include ("menu.php");
error_reporting(0);
include("config.php");
if (isset($_REQUEST['record_id'])){}
$record_id=$_REQUEST['record_id'];
echo $record_id;
//==================<!--fetching old record from db-->======================================================
$data = mysqli_query($con, "SELECT * FROM sign_up WHERE id = '$record_id'");
$res = mysqli_fetch_array($data);
$name = $res['name'];
$email = $res['email'];
$mobile = $res['mobile'];
$country = $res['country'];
$state = $res['state'];
$edu_category = $res['edu_category'];
$other_detail = $res['other_detail'];
$hobbies = $res['hobbies'];
$hob = (explode(',',$hobbies,3));
$arrlength = count($hob);
$original_doc = $res['original_doc'];
$target_path = $res['doc_path'];
//==============================================details filled in form ======================================
if(isset($_REQUEST['submit'])){
$e_name = $_REQUEST['name'];
$e_mobile = $_REQUEST['mobile'];
$e_country = $_REQUEST['country'];
$e_state = $_REQUEST['state'];
$e_edu_category = $_REQUEST['edu_category'];
$e_other_detail = $_REQUEST['other_detail'];
$e_hobbies = implode(',', $_REQUEST['hobbies']);
$e_original_doc = basename($_FILES["file"]["name"]);
$e_target_path = "../p_project/uploads/";
$e_target_path = $e_target_path . basename($_FILES["file"]["name"]);
// ===========================update Query to update on sign up form=========================================
$sql = "UPDATE sign_up SET name = '$e_name', mobile = '$e_mobile', country = '$e_country', state = '$e_state', edu_category = '$e_edu_category', other_detail = '$e_other_detail', hobbies = '$e_hobbies', original_doc = '$e_original_doc', doc_path = '$e_target_path' WHERE id = '$record_id';";
// $sql = "UPDATE sign_up SET name = '$e_name', mobile = '$e_mobile', country = '$e_country', state = '$e_state', edu_category = '$e_edu_category', other_detail = '$e_other_detail', hobbies = '$e_hobbies', original_doc = '$e_original_doc', doc_path = '$e_target_path' WHERE id = '$record_id';";
move_uploaded_file($_FILES["file"]['tmp_name'], "uploads/" . $_FILES['file']['name']); //to upload file on our $target_path = "../p_project/uploads/"
mysqli_query($con, $sql) or die(mysql_error());
header("location:showdetails.php");//after updating detail redirect to showdetails.php
// $msg = "Update successfully";
// echo "Update successfully";
}else {
// } else {
?>
<div class="contact_frm">
<h3> Update Contact Form</h3>
<form name="user_form" id="user_form" class="user_form" method="post" action="edit.php" enctype="multipart/form-data" onsubmit=" return validateform()">
<table>
<tr>
<td><label>Name:</label></td>
<td><input type="text" id="user_form_name" name="name"<?php if(isset($name) && !empty($name)){echo "value='".$name."'";} ?>/></td><!--fetching old record from db-->
<td> <span class="span1"></span></td>
</tr>
<tr>
<td><label>Email:</label></td>
<td> <input type="email" id="user_form_email" name="email"<?php if(isset($email) && !empty($email)){echo "value='".$email."'". " " . "readonly";} ?>/></td><!--fetching old record from db but readonly-->
<td><span class="span2"></span></td>
</tr>
<tr>
<td><label>Mobile:</label></td>
<td><input type="text" id="user_form_mobile" name="mobile"<?php if(isset($mobile) && !empty($mobile)){echo "value='".$mobile."'";} ?>/></td><!--fetching old record from db-->
<td><span class="span3"></span></td>
</tr>
<tr>
<td><label>Country:</label></td>
<td><select id="country" name="country"><?php echo '<option value=999>'.$res['country'].'</option>'; ?></select> </td><!--fetching old record from db-->
<td><span class="span4"></span></td>
</tr>
<tr>
<td><label>State: </label></td>
<td><select class="stateDropDown" name="state" id="state"><?php echo '<option value='.$res['state'].'>'.$res['state'].'</option>'; ?></select></td><!--fetching old record from db-->
<td><span class="span5"></span></td>
</tr>
<tr>
<td><div id="edu" class= "education">Education</div></td>
<td><input type="radio" name="edu_category" id="edu_category" value="postgraduate" <?php if ($edu_category == 'postgraduate') echo 'checked="checked"'; ?> />Post Graduate<!--fetching old record from db-->
<input type="radio" name="edu_category" id="edu_category" value="graduate" <?php if ($edu_category == 'graduate') echo 'checked="checked"'; ?>/>Graduate</td><!--fetching old record from db-->
<td><span class="span6"></span></td>
</tr>
<tr>
<td><label>Other Details</label></td>
<td><div id="selectList"><label></label><?php echo '<select><option value='.$other_detail.'>'.$other_detail.'</option></select>'; ?></div></td><!--fetching old record from db-->
<td></td>
</tr>
<tr>
<td><label>Select Your Hobbies</label></td>
<td><input type="checkbox" name="hobbies[]" id="cricket" value="cricket" <?php for ($i = 0; $i < $arrlength; $i++){ if($hob[$i] == 'cricket') echo 'checked="checked"'; } ?>>Cricket <!--fetching old record from db-->
<input type="checkbox" name="hobbies[]" id="football" value="football" <?php for ($i = 0; $i < $arrlength; $i++){ if($hob[$i] == 'football') echo 'checked="checked"'; } ?>>Football<!--fetching old record from db-->
<input type="checkbox" name="hobbies[]" id="Hockey" value="Hockey" <?php for ($i = 0; $i < $arrlength; $i++){ if($hob[$i] == 'Hockey') echo 'checked="checked"'; } ?>>Hockey</td><!--fetching old record from db-->
<td> <span class="span7"></span></td>
</tr>
<tr>
<td><label for="file">Upload New File:</label></td>
<td><input type="file" name="file" id="file"</td>
<td><span class="span8">old uploaded file :<a href = "<?php echo $res['doc_path']; ?>" download > <?= $original_doc; ?> </a></span></td><!--fetching old record from db and can be downloaded from here-->
</tr>
<tr>
<td><img id="loader" src="./img/loading.gif" style="display:none;"/></td>
<td><input type="submit" value="Submit" name ="submit" /></td>
<td><?php //echo $msg;?></td>
</tr>
</table>
</form>
include ("menu.php");
error_reporting(0);
include("config.php");
if (isset($_REQUEST['record_id'])){}
$record_id=$_REQUEST['record_id'];
echo $record_id;
//==================<!--fetching old record from db-->======================================================
$data = mysqli_query($con, "SELECT * FROM sign_up WHERE id = '$record_id'");
$res = mysqli_fetch_array($data);
$name = $res['name'];
$email = $res['email'];
$mobile = $res['mobile'];
$country = $res['country'];
$state = $res['state'];
$edu_category = $res['edu_category'];
$other_detail = $res['other_detail'];
$hobbies = $res['hobbies'];
$hob = (explode(',',$hobbies,3));
$arrlength = count($hob);
$original_doc = $res['original_doc'];
$target_path = $res['doc_path'];
//==============================================details filled in form ======================================
if(isset($_REQUEST['submit'])){
$e_name = $_REQUEST['name'];
$e_mobile = $_REQUEST['mobile'];
$e_country = $_REQUEST['country'];
$e_state = $_REQUEST['state'];
$e_edu_category = $_REQUEST['edu_category'];
$e_other_detail = $_REQUEST['other_detail'];
$e_hobbies = implode(',', $_REQUEST['hobbies']);
$e_original_doc = basename($_FILES["file"]["name"]);
$e_target_path = "../p_project/uploads/";
$e_target_path = $e_target_path . basename($_FILES["file"]["name"]);
// ===========================update Query to update on sign up form=========================================
$sql = "UPDATE sign_up SET name = '$e_name', mobile = '$e_mobile', country = '$e_country', state = '$e_state', edu_category = '$e_edu_category', other_detail = '$e_other_detail', hobbies = '$e_hobbies', original_doc = '$e_original_doc', doc_path = '$e_target_path' WHERE id = '$record_id';";
// $sql = "UPDATE sign_up SET name = '$e_name', mobile = '$e_mobile', country = '$e_country', state = '$e_state', edu_category = '$e_edu_category', other_detail = '$e_other_detail', hobbies = '$e_hobbies', original_doc = '$e_original_doc', doc_path = '$e_target_path' WHERE id = '$record_id';";
move_uploaded_file($_FILES["file"]['tmp_name'], "uploads/" . $_FILES['file']['name']); //to upload file on our $target_path = "../p_project/uploads/"
mysqli_query($con, $sql) or die(mysql_error());
header("location:showdetails.php");//after updating detail redirect to showdetails.php
// $msg = "Update successfully";
// echo "Update successfully";
}else {
// } else {
?>
<div class="contact_frm">
<h3> Update Contact Form</h3>
<form name="user_form" id="user_form" class="user_form" method="post" action="edit.php" enctype="multipart/form-data" onsubmit=" return validateform()">
<table>
<tr>
<td><label>Name:</label></td>
<td><input type="text" id="user_form_name" name="name"<?php if(isset($name) && !empty($name)){echo "value='".$name."'";} ?>/></td><!--fetching old record from db-->
<td> <span class="span1"></span></td>
</tr>
<tr>
<td><label>Email:</label></td>
<td> <input type="email" id="user_form_email" name="email"<?php if(isset($email) && !empty($email)){echo "value='".$email."'". " " . "readonly";} ?>/></td><!--fetching old record from db but readonly-->
<td><span class="span2"></span></td>
</tr>
<tr>
<td><label>Mobile:</label></td>
<td><input type="text" id="user_form_mobile" name="mobile"<?php if(isset($mobile) && !empty($mobile)){echo "value='".$mobile."'";} ?>/></td><!--fetching old record from db-->
<td><span class="span3"></span></td>
</tr>
<tr>
<td><label>Country:</label></td>
<td><select id="country" name="country"><?php echo '<option value=999>'.$res['country'].'</option>'; ?></select> </td><!--fetching old record from db-->
<td><span class="span4"></span></td>
</tr>
<tr>
<td><label>State: </label></td>
<td><select class="stateDropDown" name="state" id="state"><?php echo '<option value='.$res['state'].'>'.$res['state'].'</option>'; ?></select></td><!--fetching old record from db-->
<td><span class="span5"></span></td>
</tr>
<tr>
<td><div id="edu" class= "education">Education</div></td>
<td><input type="radio" name="edu_category" id="edu_category" value="postgraduate" <?php if ($edu_category == 'postgraduate') echo 'checked="checked"'; ?> />Post Graduate<!--fetching old record from db-->
<input type="radio" name="edu_category" id="edu_category" value="graduate" <?php if ($edu_category == 'graduate') echo 'checked="checked"'; ?>/>Graduate</td><!--fetching old record from db-->
<td><span class="span6"></span></td>
</tr>
<tr>
<td><label>Other Details</label></td>
<td><div id="selectList"><label></label><?php echo '<select><option value='.$other_detail.'>'.$other_detail.'</option></select>'; ?></div></td><!--fetching old record from db-->
<td></td>
</tr>
<tr>
<td><label>Select Your Hobbies</label></td>
<td><input type="checkbox" name="hobbies[]" id="cricket" value="cricket" <?php for ($i = 0; $i < $arrlength; $i++){ if($hob[$i] == 'cricket') echo 'checked="checked"'; } ?>>Cricket <!--fetching old record from db-->
<input type="checkbox" name="hobbies[]" id="football" value="football" <?php for ($i = 0; $i < $arrlength; $i++){ if($hob[$i] == 'football') echo 'checked="checked"'; } ?>>Football<!--fetching old record from db-->
<input type="checkbox" name="hobbies[]" id="Hockey" value="Hockey" <?php for ($i = 0; $i < $arrlength; $i++){ if($hob[$i] == 'Hockey') echo 'checked="checked"'; } ?>>Hockey</td><!--fetching old record from db-->
<td> <span class="span7"></span></td>
</tr>
<tr>
<td><label for="file">Upload New File:</label></td>
<td><input type="file" name="file" id="file"</td>
<td><span class="span8">old uploaded file :<a href = "<?php echo $res['doc_path']; ?>" download > <?= $original_doc; ?> </a></span></td><!--fetching old record from db and can be downloaded from here-->
</tr>
<tr>
<td><img id="loader" src="./img/loading.gif" style="display:none;"/></td>
<td><input type="submit" value="Submit" name ="submit" /></td>
<td><?php //echo $msg;?></td>
</tr>
</table>
</form>
No comments:
Post a Comment