Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] str_replace() i zmiana adresu przysyłanego w formularzu
Maciek_#_&
post 27.10.2010, 15:54:25
Post #1





Grupa: Zarejestrowani
Postów: 149
Pomógł: 1
Dołączył: 22.02.2010

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


Cześć,
planuję uzyskać efekt by po wpisaniu jakiegoś adresu do formularza zamieniał się w :
np:
adres.pl
zamieni sie na:
ref.pl?url=adres.pl

Pokombinowałem trochę tak:
  1. <?php
  2. if (!$_POST['adres'])
  3. {
  4. echo 'Błąd. Uzupełnij pole.';
  5. }
  6. else{
  7. $adres = $_POST['adres'];
  8. $ref = 'ref.pl?url=';
  9.  
  10. if($adres){
  11. str_replace($adres, $ref, $adres);
  12. echo $adres;
  13. }
  14. }
  15. ?>


withstupidsmiley.gif


Zwraca adres podany w formularzu smile.gif
Go to the top of the page
+Quote Post
Misiur66
post 27.10.2010, 16:04:36
Post #2





Grupa: Zarejestrowani
Postów: 170
Pomógł: 11
Dołączył: 2.03.2008
Skąd: Lublin

Ostrzeżenie: (10%)
X----


Kod
if($adres){
str_replace($adres, $ref, $adres);
echo $adres;
}


Ale po co?

Kod
if($adres){
$adres = $ref.$adres;
echo $adres;
}


Replace służy do podmiany, a ty nie masz nic.
Go to the top of the page
+Quote Post
Maciek_#_&
post 27.10.2010, 16:08:14
Post #3





Grupa: Zarejestrowani
Postów: 149
Pomógł: 1
Dołączył: 22.02.2010

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


hehe, no fakt.

Dzięki. smile.gif
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 Wersja Lo-Fi Aktualny czas: 24.07.2025 - 14:33