0

I'm wondering if some more experienced PHP coders can help me resolve this issue:

  1. I have a edit.php page which displays current client data to update in form fields.
  2. the update button that when clicked at the moment is just going to a page clients.php (Showing all clients data including the updated client data)
  3. My goal is when the update button is clicked instead of going to clients.php as a redirect and showing a table full of clients, i wish it to redirect to just the individual client info on the report.php page and have it echo the current updated client data in a table.

All i get is a syntax error below.

syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

Below is the redirect code on the edit.php page, then below that the reports.php page i want to redirect to but only echo current Client ID's data.

if($run_update){

    header("Location: reports.php?cus_id=<?php echo $result['id'] ?>"); 

          keepmsg('<div class="alert alert-success text-center">
              <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Client updated successfully.
        </div>');

} else {

  keepmsg('<div class="alert alert-danger text-center">
              <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Sorry!</strong> Client could not be updated.
        </div>');
}

Below is the simple reports.php page. This is were I'm trying to redirect to and display only the current clients data by ID

<div class="container">

<div class="jumbotron">

    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <small class="pull-right"><a href="edit.php?cus_id=<?php echo $row['id'] ?>" class='btn btn-danger'>Edit Client</a> </small>
                <h2 class="text-center invert"> Client Info: <span class="font-weight-light"><?php echo $row['deceased'] ?></span></h2>
                <hr>
            </div>
        </div>
    </div>

    <br>

    <div class="table-responsive table-wrapper">
        <table class="table table-bordered table-hover text-center">
            <thead>
                <tr>
                    <th class="text-center">Job Type</th>
                    <th class="text-center">Name of Deceased</th>
                    <th class="text-center">Plot Number</th>
                    <th class="text-center">Cemetery</th>
                </tr>
            </thead>
            <tbody class="invert_td">   
                <tr> 
                    <td><?php echo $row['jobtype'] ?></td>
                    <td><?php echo $row['deceased'] ?></td>
                    <td><?php echo $row['plot'] ?></td>
                    <td><?php echo $row['cemetery'] ?></td>
                </tr>
            </tbody>
        </table>
    </div>

</div>

Below if the 1st line of code from my form on the edit.php page if that helps

<form class="form-horizontal" role="form" method="post" action="edit.php?cus_id=<?php echo $client_id ?>">
Shadow
  • 33,525
  • 10
  • 51
  • 64
Andy Hoey
  • 27
  • 3
  • Does this answer your question? [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Shadow Apr 24 '20 at 21:17

2 Answers2

0

try header("Location: reports.php?cus_id=".$result['id']);

Mohamed
  • 1
  • 2
  • Hi Mohamed, almost fixed i think however, now i get no PHP errors, but on the report.php url the ID its blank and so is the page. This is an example of the URL i get now http://localhost:9090/wmdb/admin/reports.php?cus_id= Here is a screenshot of the new issue [link]https://ibb.co/Gsp7qn7 – Andy Hoey Apr 24 '20 at 23:56
  • it seems to work if i got back to reports and click on the more info button, it takes me to the correct place - http://localhost:9090/wmdb/admin/reports.php?cus_id=126 and i can see the data, it's just not working when i click the update button where i put the header redirect code? – Andy Hoey Apr 25 '20 at 00:05
  • you have pass $result['id'] to header() file – Mohamed Apr 25 '20 at 19:18
0

Hi Mohammed i have a function in my functions.php Though I'm not sure if this is what you meant by passing in in the header?

function redirect($page){

header("Location: {$page}{$result} ['id']");   

}

I created this function yet it still does not take me to the correct client info page e.g http://localhost:9090/wmdb/admin/reports.php?cus_id=132

only to

http://localhost:9090/wmdb/admin/reports.php?cus_id=

Andy Hoey
  • 27
  • 3