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
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. ?>


(IMG:style_emoticons/default/withstupidsmiley.gif)


Zwraca adres podany w formularzu (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
Misiur66
post
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
Post #3





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

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


hehe, no fakt.

Dzięki. (IMG:style_emoticons/default/smile.gif)
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: 22.08.2025 - 20:56