0

The PLOT

I have created a page where there is a input field for URL. What I want it to do is that when a url is entered in the input box, it should validate it, then fetch 5(as many as available but less than 5 or 5). I have successfully written a jQuery script to take the URL entered and send it to a php file (using AJAX). I used the php code in this answer : https://stackoverflow.com/a/7995399/980049 but it's generating only one image. Plus -> it's using file_get_content() function which, some are saying, is dangerous(not secure).

So, The Problem is:

The jQuery script is working fine as it can fetch the image. But the php code is only generating one image(first image).

NOTE: I have edited only the $url of the php code given in the answer and the rest is the same.

Edited Portion:

$url = $_POST['url']; // I am using type: POST in the jQuery AJAX script.
Community
  • 1
  • 1
Abhishek Biswal
  • 450
  • 5
  • 18

1 Answers1

0

The $_POST variable is an array. So you have to use array syntax to access the items.

Try doing this :

print_r($_POST) 

after the post variable is set, it will show you all of the items in the $_POST array.

After that you will just need to loop through the items to get the values you are looking for

Example:

for(var $i = 0 ; $i < count($_POST) ; i++){

    $url[] = $_POST[$i]['url'];

} 
Abhishek Biswal
  • 450
  • 5
  • 18
laymanje
  • 833
  • 5
  • 9