Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] file_get_contents - pobieranie url z formularza
kuzniarski1996
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 18.12.2015

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


Witam serdecznie, nie mogę sobie poradzić z kodem, mianowicie chodzi o to aby w miejscu gdzie znajduje się adres url, wstawić url z pola input, dokładniej: mam pole formularza w którym wpisuje url, przyciskam dalej i ma mi pokazać pobraną treść z linku który wkleiłem.

  1. <?php
  2. $content = file_get_contents('http://torrenty.org/torrent/1230967');
  3. preg_match ('[<div class="tytul_gora">(.+?)</div>]', $content, $wynik);
  4. print_r($wynik[0]);
  5. ?>

Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kuzniarski1996
post
Post #2





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 18.12.2015

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


Wciąż nie mogę sobie poradzić (IMG:style_emoticons/default/sad.gif)

Zrobiłem tak:
  1. <?php
  2. $content = file_get_contents($_POST['search']);
  3. preg_match ('[<div class="tytul_gora">(.+?)</div>]', $content, $wynik);
  4. print_r($wynik[0]);
  5. ?>


Oraz formularz:

  1. <form method="post">
  2. <div class="input-group">
  3. <input id="searchText" type="text" name="search" class="form-control" placeholder="Link url...">
  4. <div class="input-group-btn">
  5. <button id="search" type="submit" class="btn btn-primary form-control" aria-label="Search">Generuj!</button>
  6. </div>
  7. </div>
  8. </form>


Wywala komunikat:
  1. Warning: file_get_contents(): Filename cannot be empty in C:\WebServ\httpd\index.php on line 46


Ten post edytował kuzniarski1996 18.12.2015, 12:25:10
Go to the top of the page
+Quote Post

Posty w temacie


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: 6.10.2025 - 22:28