I have a customers page with an edit button. I can click the edit button, it loads the customers_edit.php page and I can edit the customer. When I click save, it grabs the customerID as the updateID and attempts to reload the customer_edit page with the updateID in the address bar but it gives me a “is currently unable to handle this request. HTTP ERROR 500” page. The address in the address bar is correct and if I simply click in the bar and hit enter, it loads the desired customer page. When I manually load the edit page, the edits have saved. What might I be missing here to get the page to re-load after updates on it’s own?
Here is the code:
<?php
require_once '../../../db_php/dbconnectiontickets.php';
$CustomerID=(isset($_GET['updateid']) ? $_GET['updateid'] : '');
//require_once '../fireytech-project/db_php/dbconnectiontickets.php';
session_start();
if(!isset($_SESSION['user'])){
header('location:../login.php');
}
$sql = "SELECT * From Customers
WHERE CustomerID ='$CustomerID'
"
;
$result = $conn->query($sql);
//echo "<pre>";print_r($result);die;
if ($result->num_rows > 0) {
$row = $result->fetch_all(MYSQLI_ASSOC);
}
/*Update ccustomers table*/
$userName=explode('@',$_SESSION['user']['firstname']);
$userName=$userName[0];
if(!empty($_POST)){
//DateEdited
$Notes=$conn->real_escape_string($row[0]['Notes']);
$NotesBilling=$conn->real_escape_string($row[0]['NotesBilling']);
$company=$conn->real_escape_string($row[0]['Company']);
// $billedAs=$row[0]['BilledAs'];
$customerSource=$row[0]['CustomerSource'];
// $customerType=$row[0]['CustomerType'];
$customerStatus=$row[0]['CustomerStatus'];
$donotcontact=$row[0]['donotcontact'];
$dcpgreeting=$row[0]['dcpgreeting'];
$dcpemailgroup=$row[0]['dcpemailgroup'];
$shareddrive=$row[0]['shareddrive'];
if($_POST['Notes'] !=''){
$Notes=date('m/d/Y h:m'). ' '.$userName .'rn'.$conn->real_escape_string($_POST['Notes']).'rn'.$conn->real_escape_string($row[0]['Notes']);
//$Notes=$conn->real_escape_string($Notes);
}
if($_POST['NotesBilling'] !=''){
$NotesBilling=date('m/d/Y h:m'). ' '.$userName .'rn'.$conn->real_escape_string($_POST['NotesBilling']).'rn'.$conn->real_escape_string($row[0]['NotesBilling']);
//$NotesBilling=$conn->real_escape_string($);
}
$company=$conn->real_escape_string($_POST['Company']);
// if($_POST['BilledAs'] !=''){
// $billedAs=$conn->real_escape_string($_POST['BilledAs']);
// }
if($_POST['CustomerSource'] !=''){
$customerSource=$conn->real_escape_string($_POST['CustomerSource']);
}
// if($_POST['CustomerType'] !=''){
// $customerType=$conn->real_escape_string($_POST['CustomerType']);
// }
if($_POST['CustomerStatus'] !=''){
$customerStatus=$conn->real_escape_string($_POST['CustomerStatus']);
}
if($_POST['donotcontact'] !=''){
$donotcontact=$conn->real_escape_string($_POST['donotcontact']);
}
if($_POST['dcpgreeting'] !=''){
$dcpgreeting=$conn->real_escape_string($_POST['dcpgreeting']);
}
if($_POST['dcpemailgroup'] !=''){
$dcpemailgroup=$conn->real_escape_string($_POST['dcpemailgroup']);
}
if($_POST['shareddrive'] !=''){
$shareddrive=$conn->real_escape_string($_POST['shareddrive']);
}
// echo "<pre>";print_r($Notes);die;
$currentDate=date('Y-m-d');
//$updateSql="UPDATE Customers SET Notes=mysqli_real_escape_string($Notes),NotesBilling=mysqli_real_escape_string($NotesBilling) WHERE CustomerID ='$CustomerID' ";
$updateSql="UPDATE Customers SET Notes='$Notes',NotesBilling='$NotesBilling',Company='$company',CustomerSource='$customerSource',CustomerStatus='$customerStatus',DateEdited='$currentDate',donotcontact='$donotcontact',dcpgreeting='$dcpgreeting',dcpemailgroup='$dcpemailgroup',shareddrive='$shareddrive'
WHERE CustomerID ='$CustomerID' ";
$conn->query($updateSql);
echo "<meta http-equiv='refresh' content='0'>";
if ($conn->error) {
printf("Error message: %sn", $conn->error);die;
}
}
//echo "<pre>";var_dump($saved);die;
?>