Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] if($_GET
Turson
post
Post #1





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


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
Go to the top of the page
+Quote Post
wookieb
post
Post #2





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




wartości atrybutów w HTML wrzuca się w cudzysłowia
Kod
atrybut="wartosc"

Kod
action="twoja_akcja"


--------------------
Go to the top of the page
+Quote Post
Turson
post
Post #3





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Poprawiłem, ale w zwiazku z moim problemem nic to nie daje
Go to the top of the page
+Quote Post
wookieb
post
Post #4





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




No to pokaż teraz cały kod. U mnie działa.


--------------------
Go to the top of the page
+Quote Post
Turson
post
Post #5





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


  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. ?>
Go to the top of the page
+Quote Post
NEO.pl
post
Post #6





Grupa: Zarejestrowani
Postów: 71
Pomógł: 5
Dołączył: 26.01.2011

Ostrzeżenie: (40%)
XX---


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?
Go to the top of the page
+Quote Post
wookieb
post
Post #7





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Jaki masz adres w przeglądarce po kliknięciu 1 przycisku?


--------------------
Go to the top of the page
+Quote Post
Turson
post
Post #8





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Po różnych 'action'. Dla jednego co innego i drugiego co innego. Dlatego to GET

@up
index.php?zmiana=haslo

Ten post edytował TursoN 25.03.2011, 16:59:14
Go to the top of the page
+Quote Post
wookieb
post
Post #9





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




No więc wszystko na pewno działa.
Wyświetla Ci napis "zmiana hasla" więc jest OK


--------------------
Go to the top of the page
+Quote Post
Turson
post
Post #10





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Właśnie mi nie wyświetla tego, a zwykły index.php
Go to the top of the page
+Quote Post
wookieb
post
Post #11





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




To tego kodu, który masz nie masz w "index.php" ?


--------------------
Go to the top of the page
+Quote Post
Turson
post
Post #12





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


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".
Go to the top of the page
+Quote Post
wookieb
post
Post #13





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




No to dlaczego linkujesz twój formularz zminy hasła do index.php questionmark.gif
"panel.php?zmiana=haslo" poprawką wartość action


--------------------
Go to the top of the page
+Quote Post
Turson
post
Post #14





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Teraz ok, a moge to w jakiś sposób zmienić bo przez panel.php? niszczy mi się stryktura strony oparta na index.php
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 22.08.2025 - 10:25