Reputation: 97
I have a database, after the redirect I want a table row to display the row information using that rows id. How would I type that?
I built an edit.php and a login.php, now when I click edit then it redirects to the login, now after I login correctly it redirects to edit.php, problem is that the edit.php is not displaying the rows for me to edit.
Assuming this is all the code that is needed, how do I correct this:
if($hash == $results[0]['hash'])
{ $_SESSION['user_id'] = $results[0]['id'];
redirect(''); } else $errors['username'] = 'Login failed.';
Ok this is the code that is working now:
if($hash == $results[0]['hash'])
{ $_SESSION['user_id'] = $results[0]['id'];
Header( "Location: http://localhost/flagship/web/edit.php?id=" . $_SESSION['user_id'] ); }
else $errors['username'] = 'Login failed.';
Just that its fetching only the first row from the table, how do I get the other rows to display?
Upvotes: 0
Views: 166
Reputation: 18022
You want to redirect the browser? try this:
Header( "Location: http://www.domain.com/web/edit.php?id=" . $row[$id] );
EDIT
with the code now in your question it would be:
if($hash == $results[0]['hash'])
{ $_SESSION['user_id'] = $results[0]['id'];
Header( "Location: http://www.domain.com/web/edit.php?id=" . $_SESSION['user_id'] ); } else $errors['username'] = 'Login failed.';
Upvotes: 0
Reputation: 1299
I think you are looking for:
header("Location: ../web/edit.php?id=$row[$id]");
Upvotes: 0
Reputation: 4374
If you have to use php to do it: http://php.net/manual/en/function.header.php
My personal favorite way to redirect is to
echo "<script>window.location('set location');</script>";
Upvotes: -3
Reputation: 57306
Use header
function:
header('location: ../web/edit.php?id=' . $row[$id]);
Upvotes: 4