<?php
include('../headertop.php');
include('../db.php');
//include('../datepicker.php');

$disp = '';
$pagetitle = 'Edit Investor Information';

if(!isset($_POST['editinvestorsubmit']))
{
echo '<meta http-equiv="refresh" content="0;URL=viewinvestors.php">';
exit;
}

$id = $_POST['id'];
$name = $_POST['name'];
$address = $_POST['address'];
$phone = $_POST['phone'];

if(empty($id) or empty($phone) or empty($address) or empty($name))
{
$sm = '<span class="error">Please fill all required details</span>';
echo '<meta http-equiv="refresh" content="0;URL=editinvestor.php?sm='.$sm.'&id='.$id.'">';
exit;
}

$q = "update investor set name='$name', address='$address', phone='$phone' where id='$id'";

//mysqli_autocommit($dbcon, false);

$res = mysqli_query($dbcon,$q);

if(!$res)
{
$disp .= '<span class="error">Changes could not be saved: '.mysqli_error($dbcon).'</span>';
include('../template.php');
exit;
}
$sm = "Investor details edited";

echo '<meta http-equiv="refresh" content="0;URL=editinvestor.php?sm='.$sm.'&id='.$id.'">';