•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,721 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,584 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 556 | Replies: 11
![]() |
hi guys,
I found a simple whois script and intregrated it completely into my site before testing it on IE (oooops!) and it only works on firefox and safari. On IE the result text that should be written as a result of the below section of the code:
dosnt show up... the script im using is below.
Any ideas why not?
Thanks for the help,
Max
I found a simple whois script and intregrated it completely into my site before testing it on IE (oooops!) and it only works on firefox and safari. On IE the result text that should be written as a result of the below section of the code:
if (eregi('No match',$result)) {
echo 'Domain Name '.$_POST['domain'].' is free.';dosnt show up... the script im using is below.
<?
if ($_POST['type']!="") define('TYPE', $_POST['type']); else define('TYPE', '');
if ($_POST['domain']!="") define('DOMAIN', $_POST['domain']); else define('DOMAIN', '');
// .com domains
define('COM_SERVER', "rs.internic.net"); // server to lookup for domain name
define('COM_NOMATCH', "No match"); // string returned by server if the domain is not found
define('COM_INCLUDE', true); // include this domain in lookup
function search_form($error){
echo $error;
?>
<form name="whois" method="post" action="">
<input name="domain" style="text-align:center" type="text" id="domain" value="Choose your domain!" />
<input name="Search" type="submit" id="Search" value="Go!">
</form>
<?
}
if($_REQUEST['Search']){
if($error){
search_form($error);
}
else{
$ns = fsockopen('rs.internic.net',43);
fputs($ns, $_POST['domain']."\r\n");
$result = '';
while(!feof($ns)) $result .= fgets($ns,128);
fclose($ns);
if (eregi('No match',$result)) {
echo 'Domain Name '.$_POST['domain'].' is free.';
}
else {
echo 'Domain Name '.$_POST['domain'].' is not available.';
}
}
}
else{
search_form($error);
}
?>Any ideas why not?
Thanks for the help,
Max
Economizerz Hosting
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
Umm.. I tried this script. It worked only for www.yahoo.com (on both mozilla and firefox). It didn't work for www.microsoft.com , www.daniweb.com or even www.whois.net.
I think something is wrong with the script.
Edit: It worked for www.msn.com
I think something is wrong with the script.Edit: It worked for www.msn.com
Last edited by nav33n : Jul 14th, 2008 at 2:34 pm.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
ah well i took out all of the irelavent information before posting it - for example at the moment if the whois dosnt find anything for a domain it will write a paypal add to basket button so i took all that out and in the process might have killed it a bit 
here is an example of where the script is working:
http://www.economizerz.com/daniweb/w...iptexample.php
the full script im currently using is:
Max

here is an example of where the script is working:
http://www.economizerz.com/daniweb/w...iptexample.php
the full script im currently using is:
<?
if ($_POST['type']!="") define('TYPE', $_POST['type']); else define('TYPE', '');
if ($_POST['domain']!="") define('DOMAIN', $_POST['domain']); else define('DOMAIN', '');
// .com domains
define('COM_SERVER', "rs.internic.net"); // server to lookup for domain name
define('COM_NOMATCH', "No match"); // string returned by server if the domain is not found
define('COM_INCLUDE', true); // include this domain in lookup
function search_form($error){
echo $error;
?>
<center><form name="whois" method="post" action="">
<input name="domain" style="text-align:center" type="text" id="domain" value="Choose your domain!" onclick="clearwhois();" onblur="returnwhois()" />
<input name="Search" type="submit" id="Search" value="Go!">
</form></center>
<?
}
if($_REQUEST['Search']){
if($error){
search_form($error);
}
else{
$ns = fsockopen('rs.internic.net',43);
fputs($ns, $_POST['domain']."\r\n");
$result = '';
$suffix = strstr($_POST['domain'], '.');
if ($suffix == '.co.uk') $suffixprice = '3';
if ($suffix == '.com') $suffixprice = '5';
if ($suffix == '.net') $suffixprice = '8';
while(!feof($ns)) $result .= fgets($ns,128);
fclose($ns);
if (eregi('No match',$result)) {
echo '<center><form name="whois" method="post" action="">
<input name="domain" style="text-align:center" type="text" id="domain" value="Choose your domain!" onclick="clearwhois();" onblur="returnwhois()" />
<input name="Search" type="submit" id="Search" value="Go!">
</form>
<table border="0" cellpadding="0" cellspacing="3"><tr><th align="center" valign="middle" scope="col"><img src="../../images/other/tick.png"></tr><th align="center" valign="middle" scope="col">Domain Name '.$_POST['domain'].' is free.</tr></table><br /></form>
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="submit" value="Add to basket!">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="example@email.com">
<input type="hidden" name="item_name" value="'.$_POST['domain'].'">
<input type="hidden" name="amount" value="'.$suffixprice.'">
<input type="hidden" name="item_number" value="">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="lc" value="GB">
<input type="hidden" name="bn" value="PP-ShopCartBF">
</form>
</center>
';
}
else {
echo '<center><form name="whois" method="post" action="">
<input name="domain" style="text-align:center" type="text" id="domain" value="Choose your domain!" onclick="clearwhois();" onblur="returnwhois()" />
<input name="Search" type="submit" id="Search" value="Go!">
</form>
<table border="0" cellpadding="0" cellspacing="3"><tr><th align="center" valign="middle" scope="col"><img src="../../images/other/cross.png"></tr><th align="center" valign="middle" scope="col">Domain Name '.$_POST['domain'].' is not available.</tr></table><br /></form></center>';
}
}
}
else{
search_form($error);
}
?>Max
Last edited by MaxMumford : Jul 14th, 2008 at 3:34 pm.
Economizerz Hosting
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
Nope. Still the same result. Maybe you would like to use this script 
http://www.hotscripts.com/PHP/Script...ois/index.html (Max's Whois). I have tried it and it works like a charm!

http://www.hotscripts.com/PHP/Script...ois/index.html (Max's Whois). I have tried it and it works like a charm!
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
Ah thanks for the new script. Im testing it all out but I do have one problem which is that I cant integrate a .co.uk domain suffix into it.
this is an example of the code used to check the .com suffix:
and this is what i wrote (at the end of the suffix list) to try and get .co.uk working
iv tried quite a few different servers and none of them work however i think the problem its the .uk section of it (presumerably the ".") because when I put .uk it works normally but obviously dosnt find a proper result. do you have any idea how to fix it? I think it might be more complicated than just adding my .co.uk section but i cant find any support from any of the websites holding the script or any other forums.
Thanks
(youv been helping me with web designing for AAAAGES now!! its MUCH appreciated
)
Max
this is an example of the code used to check the .com suffix:
$this->serverList[0]['top'] = 'com'; $this->serverList[0]['server'] = 'whois.crsnic.net'; $this->serverList[0]['response'] = 'No match for'; $this->serverList[0]['check'] = true;
and this is what i wrote (at the end of the suffix list) to try and get .co.uk working
$this->serverList[9]['top'] = 'co.uk'; $this->serverList[9]['server'] = 'whois.nic.uk'; $this->serverList[9]['response'] = 'No match for'; $this->serverList[9]['check'] = false;
iv tried quite a few different servers and none of them work however i think the problem its the .uk section of it (presumerably the ".") because when I put .uk it works normally but obviously dosnt find a proper result. do you have any idea how to fix it? I think it might be more complicated than just adding my .co.uk section but i cant find any support from any of the websites holding the script or any other forums.
Thanks
(youv been helping me with web designing for AAAAGES now!! its MUCH appreciated
)Max
Economizerz Hosting
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
Argh! You are right. Php doesn't like . in the names of form elements. It replaces . by _.
Hmm.. strange! Lets see if someone else has an idea !
php Syntax (Toggle Plain Text)
<?php print_r($_POST); ?> <html> <body> <form method="post"> <input type="text" name="some.name"> <input type="submit" name="submit.1" value="submit"> </form> </body> </html>
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 592
Reputation:
Rep Power: 2
Solved Threads: 52
Since "_" is an invalid character for a domain, does that mean that you will never have an underscore in the any of the form entity names?
if so, you could try this
it does work.
if so, you could try this
php Syntax (Toggle Plain Text)
foreach($_POST as $key=>$value) { $_POST[str_replace("_", ".", $key)] = $value; } print_r($_POST); echo "<br />" . $_POST['.co.uk'];
Last edited by R0bb0b : Jul 15th, 2008 at 1:59 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
Thanks r0bb0b and nav33n however im not quite sure what to do with the code.
presumerably i put it at the beginning of the php script to make sure that it changes all strings with an underscore to have full stops instead however im not sure what $key or $value are meant to be.
I have a domain name field called "domain" and checkboxes for domain suffixes to be checked called "top_". its the domain field where the underscores need to be changed to fullstops
thanks again
presumerably i put it at the beginning of the php script to make sure that it changes all strings with an underscore to have full stops instead however im not sure what $key or $value are meant to be.
I have a domain name field called "domain" and checkboxes for domain suffixes to be checked called "top_". its the domain field where the underscores need to be changed to fullstops
thanks again
Economizerz Hosting
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
•
•
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 592
Reputation:
Rep Power: 2
Solved Threads: 52
You know that there are two parts to an array cell(or what ever you want to call it) right?
array[0] = "red";
echo array[0] and get "red";
0 is the key.
"red" is the value.
so, you can do a foreach loop with just he value like this
or with key and value
Maybe that will help, ya?
You can stick it at the very top of the script and it will replace all "_" with "." in the $_POST names.
array[0] = "red";
echo array[0] and get "red";
0 is the key.
"red" is the value.
so, you can do a foreach loop with just he value like this
php Syntax (Toggle Plain Text)
foreach($array as $value) { $value = "red"; }
php Syntax (Toggle Plain Text)
foreach($array as $key=>$value) { $key = 0; $value = "red"; }
You can stick it at the very top of the script and it will replace all "_" with "." in the $_POST names.
Last edited by R0bb0b : Jul 15th, 2008 at 9:13 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
Ahhh okay I see so it finds any array's where co_uk is written and converts it to co.uk
- i got a parse error:
possibly my server is using an old version of php or something?
- i got a parse error:
Parse error: syntax error, unexpected T_FOREACH, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/sites/economizerz.com/public_html/test/maxwhois/maxWhois.class.php on line 8
<?php
class maxWhois{
var $serverList;
var $tr = 0;
foreach($_POST as 9 = 'co_uk')
{
$_POST[str_replace("_", ".", $key)] = $value;
}
print_r($_POST);
echo "<br />" . $_POST['.co.uk'];possibly my server is using an old version of php or something?
Economizerz Hosting
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
Price Beater Promise
10% Cheaper Hosting, & Double Bandwidth and Web Space
Click here to apply
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
age amd avatar blue gene business chips database development dos economy energy enterprise environment hardware ibm ibm. news intel ibm it linux medicine memory microsoft news office open source openoffice pc ps3 recession red hat remote working russia security sex sun supercomputer supercomputing technology trends ubuntu working x86
- Previous Thread: PHP 4.3 - Running stored procedures
- Next Thread: File upload problem



Linear Mode