Situation: I have a member database overview where the user can click on an 'update member' link in a table that redirects to a page showing the data of clicked member. In the url it gets the parameter lid.php?lidnummer=4 (of any other id).
On that page is a form that allows the user to add a phone number to that member which goes through the create.php file after pressing the submit button. This page should redirect back to the member page lid.php?lidnummer=4 with the new phone number added.
I am passing the lidnummer through a hidden form field and I try to use this in the header() function.
header("location: ../lid.php?lidnummer=' . $lidnummer . '");
Only after the redirect the url shows:
lid.php?lidnummer=%27%20.%205%20.%20%27
and I get a 'call to a member function' error on the page, because the page displays the member data through a function that grabs the lidnummer as parameter through $_GET after pressing the 'update member' button.
<?php
if(isset($_GET['lidnummer']))
{
include 'includes/read.php';
$lidnummer = $_GET['lidnummer'];
?>
<div class="contact-form">
<h3>Voeg contactgegevens toe:</h3>
<form action="includes/create.php" method="POST"><b>
<label for="telefoonnummer">
Telefoonnummer:
<input type="text" name="telefoonnummer">
</label>
<input type='hidden' name='lidnummer' value='<?php echo $lidnummer ?>'>
<button type="submit" name='add_telnr'>Voeg telnr toe</button>
</form><br>
<form action="includes/create.php" method="POST">
<label for="email">
Email:
<input type="text" name="email">
</label>
<button type="submit" name='add_email'>Voeg email toe</button></b>
</form><br>
</div>
<div>
<h3>Lid:</h3>
<table>
<tbody>
<tr>
<td>#</td>
<td>Info</td>
<td>Pas aan</td>
<td>Delete</td>
</tr>
<?php show_single_lid($conn, $lidnummer); ?>
</tbody>
</table>
</div>
<?php } ?>
So I have 2 questions:
- How do I get the create.php file to redirect back to the lid.php page with the correct url parameter (lidnummer) after adding the phone number?
- How (if solving 1 doesn't fix this) do I then again pass the lidnummer to the lid.php page to show the data of that member again but updated?