0

This just happened recently, i have a well written registration form page, login form and sign-out button, i just noticed my sign-out button is not working and also my signup button as they were both working fine initially. I am using Xampp.

Here is my signout.php.

<?php
session_start(); 
session_destroy();
header("Location: home.php");
?>

and here is my signout button code

<form> <form action="signout.php"> <button>SIGN OUT</button></form>

I have a long sign-in code so I cant paste that here, but I think the problem is related.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Specter
  • 3
  • 3
  • when visiting signout.php, does it redirect to home.php ? if so comment the header function and see if there is any errors. – Spoody Feb 08 '17 at 16:01
  • no..it doesnt, when i click the signout button nothing happens, and it was ok recently.. – Specter Feb 08 '17 at 16:03
  • see if this answer helps http://stackoverflow.com/questions/12525251/header-location-not-working-in-my-php-code – Spoody Feb 08 '17 at 16:05
  • it doesn't redirect, when i login and click the sign out button nothing happens – Specter Feb 08 '17 at 17:15
  • Thanks but the link didint help.. – Specter Feb 08 '17 at 17:33
  • If it doesn't redirect as you say check if output is sent to client before setting the location header. – Andreas Feb 08 '17 at 18:05
  • This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting. – David Rawson Feb 09 '17 at 00:47
  • 1
    Don't edit the question to say thanks now that the problem has been fixed! You can post your own answer if you want, or use comments to say "thanks"! – David Rawson Feb 09 '17 at 00:48

1 Answers1

0

You are having a problem with your form i think,

<form> <form action="signout.php"> <button>SIGN OUT</button></form>

change it to this

<form action="signout.php">
 <button type="submit">SIGN OUT</button>
</form>

why are you using a form instead of a link ?

Spoody
  • 2,852
  • 1
  • 26
  • 36
  • Thanks medhi, my signout button now works perfectly, but am still have issues with my signup page.I am recently unable to add data to my database via sign up form, it was working fine i dont know what i did wrong again.. – Specter Feb 09 '17 at 00:36
  • @Specter if this answer solves your problem you can mark it as Solved, if you have another problem you should open another question, i'll pay a visit to see what's the problem. – Spoody Feb 09 '17 at 00:39