Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] if($_GET
Forum PHP.pl > Forum > Przedszkole
Turson
Mam kod
  1. <?PHP
  2. if($_GET["zmiana"]=="haslo"){echo "zmiana hasla";}
  3. if($_SESSION["zalogowany"]==1){
  4. echo "<table border=0><tr><td>
  5. <u>Zmiana hasla</u></td></tr><tr><td>
  6. <form action=?zmiana=haslo method=post>
  7. Nowe haslo :</td><td><input type=text size=30 name=haslo> </td><td><input type=submit value=Zmien class=button></form></td></tr>
  8. <tr><td><u>Zmiana e-maila</u></td></tr><tr><td>
  9. <form action=index.php?zmiana=mail method=post>
  10. Nowy adresu e-mail </td><td>:<input type=text size=30 name=mail> </td><td><input type=submit value=Zmien class=button></td></tr></table></form><br>
  11. ";}
  12. else {echo "Musisz byc zalogowany!";}
  13. ?>

Klikajac na button przy pierwszym inpucie nie zwraca tekstu "zmiana hasla" ..nie czaje
wookieb
wartości atrybutów w HTML wrzuca się w cudzysłowia
Kod
atrybut="wartosc"

Kod
action="twoja_akcja"
Turson
Poprawiłem, ale w zwiazku z moim problemem nic to nie daje
wookieb
No to pokaż teraz cały kod. U mnie działa.
Turson
  1. <?PHP
  2. if($_GET["zmiana"]=="haslo"){echo "zmiana hasla"; }
  3. if($_SESSION["zalogowany"]==1){
  4. echo '<table border="0"><tr><td>
  5. <u>Zmiana hasla</u></td></tr><tr><td>
  6. <form action="?zmiana=haslo" method="post">
  7. Nowe haslo :</td><td><input type="text" size="30" name="haslo"> </td><td><input type="submit" value="Zmien" class="button"></form></td></tr>
  8. <tr><td><u>Zmiana e-maila</u></td></tr><tr><td>
  9. <form action="index.php?zmiana=mail" method="post">
  10. Nowy adresu e-mail </td><td>:<input type="text" size="30" name="mail"> </td><td><input type="submit" value="Zmien" class="button"></td></tr>
  11. </table></form><br>
  12. ';}
  13. else {echo "Musisz byc zalogowany!";}
  14. ?>
NEO.pl
Cytat(TursoN @ 25.03.2011, 16:39:19 ) *
<input type=submit value=Zmien class=button>
<input type=submit value=Zmien class=button>


W jaki sposob planujesz rozpoznac ktory submit nacisnieto?
wookieb
Jaki masz adres w przeglądarce po kliknięciu 1 przycisku?
Turson
Po różnych 'action'. Dla jednego co innego i drugiego co innego. Dlatego to GET

@up
index.php?zmiana=haslo
wookieb
No więc wszystko na pewno działa.
Wyświetla Ci napis "zmiana hasla" więc jest OK
Turson
Właśnie mi nie wyświetla tego, a zwykły index.php
wookieb
To tego kodu, który masz nie masz w "index.php" ?
Turson
Index.php
  1. //html
  2. <?PHP
  3. $id = $_GET["id"];
  4. if ($id=="")
  5. {
  6. include("news.php");
  7. }
  8.  
  9. else {
  10.  
  11. if (is_file("$id.php"))
  12. {
  13. include("$id.php");
  14. }
  15.  
  16. else
  17. {
  18. include("error.php");
  19. }
  20. }
  21.  
  22.  
  23. ?>
  24. //html

Panel.php
  1. <?PHP
  2. if($_GET["zmiana"]=="haslo"){echo "zmiana hasla"; }
  3. if($_SESSION["zalogowany"]==1){
  4. echo '<table border="0"><tr><td>
  5. <u>Zmiana hasla</u></td></tr><tr><td>
  6. <form action="?zmiana=haslo" method="post">
  7. Nowe haslo :</td><td><input type="text" size="30" name="haslo"> </td><td><input type="submit" value="Zmien" class="button"></form></td></tr>
  8. <tr><td><u>Zmiana e-maila</u></td></tr><tr><td>
  9. <form action="index.php?zmiana=mail" method="post">
  10. Nowy adresu e-mail:</td><td><input type="text" size="30" name="mail"> </td><td><input type="submit" value="Zmien" class="button"></td></tr>
  11. </table></form><br>
  12. ';}
  13. else {echo "Musisz byc zalogowany!";}
  14. ?>

News.php
  1. <?php
  2. if($_GET["wyloguj"]=="tak"){$_SESSION["zalogowany"]=0;echo "Zostałeś wylogowany z serwisu";}
  3. if($_SESSION["zalogowany"]!=1){
  4. if(!empty($_POST["login"]) && !empty($_POST["haslo"])){
  5. if(mysql_num_rows(mysql_query("select * from users where user_login = '".htmlspecialchars($_POST["login"])."' AND user_haslo = '".htmlspecialchars($_POST["haslo"])."'"))){
  6. echo 'Zalogowano poprawnie jako '.$_SESSION['login'].'. <a href=index.php>Przejdz na strone główna</a>';
  7.  
  8. $_SESSION["zalogowany"]=1;
  9. $_SESSION['login'] = $_POST['login'];
  10.  
  11. }
  12. else echo ShowLogin("Podano złe dane!!!");
  13. }
  14. else ShowLogin();
  15. }
  16. else{
  17. $nick = $_POST["login"];
  18. echo "<a href=?wyloguj=tak>Wyloguj</a>";
  19. include("glowna.php"); ?>
  20. <?php
  21. }
  22. ?>
  23.  

Tak to wyglada. W news.php mi includuje glowna.php ale tam jedynie tekst typu "witaj".
wookieb
No to dlaczego linkujesz twój formularz zminy hasła do index.php questionmark.gif
"panel.php?zmiana=haslo" poprawką wartość action
Turson
Teraz ok, a moge to w jakiś sposób zmienić bo przez panel.php? niszczy mi się stryktura strony oparta na index.php
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.