Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP][MYSQL]Problem z wykonywaniem...
-Keffrg-
post
Post #1





Goście







Mam problem. Jak daję na przycisk remove to zamiast pojawiać się napis, że "User has been deleted" to przenosi mnie na stronę admin.php . Dlaczego tak się dzieje? I w ogóle kodu nie wykonuje bo na to wygląda. Kod:

  1. <?php 
  2.  
  3.  
  4. if (!isset($_SESSION['admin'])) {
  5.  
  6.  
  7. } 
  8.  
  9. else {
  10.  
  11. echo '
  12. <link rel="Stylesheet" href="adminstyle.css" type="text/css" />
  13. <div id="all">
  14. <div id="menu">
  15. <ul class="menu">
  16. <li><a href="admin.php">Home</a></li>
  17. <li><a href="admin.php?mod=removeuser">Remove</a></li>
  18. <li><a href="#">Add admin</a></li>
  19. <li><a href="#">Edit</a></li>
  20. <li><a href="logout.php">Log out</a></li>
  21. </ul>
  22. </div>
  23. </div>';
  24.  
  25. mysql_connect ('localhost','root','mentormiszcz1e');
  26.  
  27. switch ($_GET['mod']) {
  28.  
  29. default:
  30.  
  31. echo '<div id="end">' . 'Yo, yo ' . $_SESSION['admin'] . ' You rule here (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) .' . '</div>';
  32.  
  33. break;
  34.  
  35. case 'removeuser':
  36.  
  37. echo '<div id="end">
  38. <form action="admin.php" method="post">
  39. <div id="form">
  40. Type a nick of user: <input type="text" name="remove" />
  41. <input type="submit" value="Remove" />
  42. </div>
  43. </form>
  44. </div>';
  45.  
  46. if (!empty($_POST['remove'])) {
  47.  
  48. echo 'User has been deleted :)';
  49.  
  50. }
  51.  
  52. else {
  53.  
  54. echo 'This user does not exist (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) ';
  55.  
  56. }
  57.  
  58. break;
  59.  
  60. }
  61.  
  62. }
  63.  
  64. ?>
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Cytat
o przenosi mnie na stronę admin.php
bo w formularzu dales by cie przenosil na admin.php to cie przenosi.

skoro dajesz warunek: empty($_POST['remove']) to twoj przycisk usuwania powinien miec name="remove" a teraz nie ma. ma tylko value="remove" (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
piotrooo89
post
Post #3


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




jak napisał nospor daj sobie zamiast

  1. <?php
  2. <form action="admin.php" method="post">
  3. ?>

na
  1. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Go to the top of the page
+Quote Post
-Keffrg-
post
Post #4





Goście







Ok, już chodzi (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) . Przez takie głupie rzeczy można się normalnie pogubić (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) .Dzięki za wszystko.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 04:16