ziyad ziyad - 1 month ago 10
HTML Question

redirect to another page

hello guys i have this problem that i couldn't solve the thing is i have two buttons one for delete and the other for edit, the delete is working flawlessly, but edit button doesn't seems to work to make it redirect to a php file + how i can get the meeting name with edit button when it's redirect to another page don't know how here's my code

<table class="table table-striped custab" >
<thead>
<tr>
<th>Title</th>
<th>Chairman</th>
<th>Summary</th>
<th> Date & Time</th>
</tr>
<?php

$findMeetings = "SELECT * FROM `meeting` WHERE chairman='".$name."'";

$result = mysqli_query($db, $findMeetings);

$numRows = mysqli_num_rows($result);

if($numRows == 0){

$empty = "<div class='alert alert-danger'>You are currently managing no meetings!</div>";

}
else{

$x = 0;

while($rows = mysqli_fetch_array($result)){

$title = $rows['title'];
$chairman = $rows['chairman'];
$date = $rows['time'];
$summary = $rows['summary'];

$meeting = "
<tr>
<th>".$title."</th>
<th>".$chairman."</th>
<th>".$summary."</th>
<th>".$date."</th>
<th><form method='post'>
<input type='submit' class='btn btn-success' name='edit".$x."' value='Edit'/>
<input type='submit' class='btn btn-danger' name='delete".$x."' value='Delete'/>
</form></th>
</tr>
";

echo $meeting;

if(isset($_POST['delete'.$x.''])){

$query = "DELETE FROM meeting WHERE title='".$title."' LIMIT 1";

if($result = mysqli_query($db, $query)){

header("Location:managemeeting.php");

}

}



}

}

?>

</thead>
<tbody>

</tbody>
</table>


so how to get the meeting name and the passed it to editmeeting.php cause there's multiple data.

if i do it like delete button nothing happen like this

if(isset($_POST['edit'.$x.''])){



header("Location:editMeeting.php");

}

Answer

You should wrap a <form> around each submit button, and specify the action in each <form> so that it posts to the correct url with respect to the button the <form> is wrapped around.

Then use <hidden> fields inside each <form> to pass data to the url you are posing to example: <input type="hidden" name="row_id" value="99" />

Comments