Can anybody please help me? I pay $20
Posted: Wed Jul 07, 2010 12:21 pm
Hi
I am a newbie in PHP and have been trying to solve this problem for days without any luck.. I tested alot by myself, asked in plenty of forums and even asked my previous programmer for help without any luck..
So now I want your help and I will pay $30 via PayPal to the person who figure this out.
Here is the problem:
I am trying to redirect a page to another page when a certain keyword is submitted in a text field. Both the keywords and the URL“s it will redirect to will be pulled from a database.
My code looks like this:
When I submit the form it gives me the following error code:
This is where I am stuck 
If you want to help me over MSN or Skype let me know and I will send you my info...
Thanks in advance
I am a newbie in PHP and have been trying to solve this problem for days without any luck.. I tested alot by myself, asked in plenty of forums and even asked my previous programmer for help without any luck..
So now I want your help and I will pay $30 via PayPal to the person who figure this out.
Here is the problem:
I am trying to redirect a page to another page when a certain keyword is submitted in a text field. Both the keywords and the URL“s it will redirect to will be pulled from a database.
My code looks like this:
Code: Select all
<?php
ini_set("display_errors", true);
error_reporting(-1);
header("Location: $redir");
exit;
include("connect.php");
$extract = mysql_query("SELECT * FROM engines");
$numrows = mysql_num_rows($extract);
$i = "0";
while ($row = mysql_fetch_array($extract))
{
$id=$row['id'];
$name[$i]=$row['name'];
$url[$i]=$row['url'];
$searchurl[$i]=$row['searchurl'];
$keyword[$i]=$row['keyword'];
$i++;
}
function wordsExist(&$string, $words) {
foreach($words as &$word) {
if(stripos($string, $word) !== false) {
return true;
}
}
return false;
}
function wordExist(&$string, $string) {
if(stripos($string, $string) !== false) {
return true;
}
return false;
}
{
$keyword = preg_replace('/([a-zA-Z0-9]*(\s){0,1}):/','',$search);
$shop = preg_replace('/:([a-zA-Z0-9]*(\s){0,1})/','',$search);
}
if (wordExist($search, $keyword))
{
$redir = "http://domain.com"; //this should be a URL!
break;
}
elseif (wordsExist($search, array('http://'))) {
$redir = $search; //this should be a URL!
}
elseif (wordsExist($search, array('.com','.net','.org','.aero','.asia','.biz','.cat','.coop','.edu','.gov','.info','.int','.jobs','.mil','.mobi','.museum','.name','.pro','.tel','.travel','.ac','.ad','.ae','.af','.ag','.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.ax','.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.er','.es','.et','.eu','.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gb','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gw','.gy','.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki','.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.me','.mg','.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rs','.ru','.rw','.sa','.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.su','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tl','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.wf','.ws','.ye','.yt','.za','.zm','.zw')))
{
$redir = "http://$search"; //this should be a URL!
}
elseif (wordsExist($search, array('tlf:')))
{
$redir = "http://opplysning1890.no/index.php?q=$keyword&type=privat"; //this should be a URL!
}
elseif (wordsExist($search, array(':')))
{
echo "There is no search engine connected with <b>$shop</b>. If you want to suggest a search engine please <a href=\"suggest.php\">click here</a>. If you rather want to search in Google for <b>$keyword</b>, please <a href=\"http://www.google.com/search?q=$keyword\">click here</a>.<br />";
}
else
{
$redir = "http://www.google.com/search?q=$search";
}
?>Code: Select all
Notice: Undefined variable: redir in /home/haukaas/public_html/new/search.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at /home/haukaas/public_html/new/search.php:6) in /home/haukaas/public_html/new/search.php on line 6If you want to help me over MSN or Skype let me know and I will send you my info...
Thanks in advance