Jump to content

Form selection keeps opening a link on second attempt and onwards


Modernvox

Recommended Posts

I currently have a drop down form that allows users to select a state which display ads (Scraped from website). The problem is the form only works for the first use. Additional attempts will open a link from the previous process.

In other words instead of displaying the new results it opens the last imported row from previous process?

 

  <?php
$st = isset($_POST['submit']) ? $_POST['state'] : '';

$urls = array();

if ($st == "AL") 
{
echo "Over 500 results detected! You may also search by city.";
$urls = array("http://auburn.craigslist.org", "http://bham.craigslist.org");
}
else if ($st == "AK") 
{
$urls= array("http://anchorage.craigslist.org");
}
else if ($st == "AZ") 
{
$urls = array("http://anchorage.craigslist.org");
}

foreach ($urls as $url) {
    $html = file_get_contents("$url/muc/");

    preg_match_all('/<a href="([^"]+)">([^<]+)<\/a><font size="-1">([^"]+)<\/font>/s', $html,$posts,PREG_SET_ORDER);
    //echo "<pre>";print_r($posts);
$i = 1; //set start point;
$limit = 65; //set limit;
foreach ($posts as $post) {
   //print $post[0]; //HTML
   $post[2] = str_ireplace($url,"",$post[2]); //remove domain
   echo "<a href=\"$url{$post[1]}\">{$post[2]}<font size=\"3\">{$post[3]}<br />";
   print "<BR />\n";


   if ($i == $limit)
   {
      break;
   }
   $i++;
}
}
?>

 

Thanks in advance

Hi Zanus,

 

Would you know why after I process a selection from my drop down form it only returns the values once.  All subsequent selections link to the last result on previous selection?

 

The page is here if you have a sec to troubleshoot.

http://dezi9er.net16.net/page2.php

 

Please don't PM me questions.

 

As for your code... I don't see the form doing anything..

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.