Solved

CGI Searcher

Posted on 2001-07-28
9
173 Views
Last Modified: 2013-12-25
Dear Sir,

What I want is - I wanted a text file and on that file, whenever anyone registered them selves like, Let say domains registration process. when ever user register thier domain like www.anything.com it will search the text file and tell them if the domain is available i dont wanted to involve INTERNIC WHOIS DATABASE, when ever user register thier domain , thru web interface form and let say the user is looking for www.ab.com and that domain is available and then user hit submit button after submitting the form and when he submit the form, the ab.com is got in to the text file on my server, so after if any other user is looking for the ab.com it will tell them that ab.com is already book.. by looking the text file. how I am going to do that. Please let me know. Thanks.
0
Comment
Question by:sohaib69
  • 6
  • 3
9 Comments
 
LVL 8

Expert Comment

by:bebonham
ID: 6330300
so you don't care if the domain is registerd with internic

right?

this is purely internal?
0
 
LVL 1

Author Comment

by:sohaib69
ID: 6330770
yes this is purly internal...
0
 
LVL 8

Accepted Solution

by:
bebonham earned 100 total points
ID: 6330789
here is a crude example

#!/usr/local/bin/perl

use CGI ':standard';




### vars

$dfile='domain.txt';  ##datafile for storing domain names
####


print header, start_html;


if(!param())
{
if(-e $dfile)
{
open NAMES, $dfile;

@names=<NAMES>;
close NAMES;

print "the names already in use are:<BR>";
foreach(@names)
{
print "$_<BR>";
}
}
print "pick a domainname like books.com<BR>";
print start_form,
textfield(-name=>'domain'), submit();
}

if(param('domain'))
{
my $d=param('domain');
open NAMES, $dfile;

while(<NAMES>)
{
if($_=~/$d/i)
{
print h1('sorry that is taken');
exit;
}
}
close NAMES;

open NAMES, ">>$dfile";
print NAMES param('domain') . "\n";
close NAMES;
print "done, hit back button and reload prev. page";
}
0
 
LVL 1

Author Comment

by:sohaib69
ID: 6330800
Is that a script which can tell if the domain is taken or not right, so how is going to be the html file

when ever user submit the form by putting the domain what is going to be the field name of the domain box , so that it can tell if the domain is taken or not.

thanks for ur help
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:sohaib69
ID: 6330803
$dfile='domain.txt';  ##datafile for storing domain names

and that file is going to be like

$dfile='/home/www/domain.txt';  ##datafile for storing domain names

the location of the text file right..

0
 
LVL 1

Author Comment

by:sohaib69
ID: 6330811
what is the problem with that script is, when ever I look for the domain like abc.com it's just storing the domain. like i do abc.com , and yahoo.com first it says , after putting yahoo.com done, hit back button and reload prev. page.. then after I reload page it show that name yahoo.com on that file..

What I want the user can look for a domain by html form and then this file can tell if the domain is available, and then after this script registered the domain by storing on that domain.txt .. You know what I mean
0
 
LVL 1

Author Comment

by:sohaib69
ID: 6330836
Excellen question thats what I am looking for, and you made my work more easier, but also as I mention on my next ticket please tell me what to do with that .. Thanks
0
 
LVL 1

Author Comment

by:sohaib69
ID: 6331024
the script Accepts anything, like if you enter books.tatat.tete or books.sex or anything .  let say if I wanted to limit the script to search only .net and nothing else except for .net how I am going to do that. so that no one cant search that script to books.com or books.tatat.tete or books.com just only books.net where I wILL modify the script so that it will just search .net let me know please..
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6331941
try this:

#!/usr/local/bin/perl

use CGI ':standard';




### vars

$dfile='domain.txt';  ##datafile for storing domain names
@allowedDomains=qw/.net .com .org/;  ## only accept these domains

####


print header, start_html;


if(!param())            

if(-e $dfile)
{
open NAMES, $dfile;

@names=<NAMES>;
close NAMES;

print "the names already in use are:<BR>";
foreach(@names)
{
print "$_<BR>";
}
}
print "pick a domainname like books.com<BR>if your name is taken ";
print "or if it is not valid we will return an error message\n";
print start_form,
textfield(-name=>'domain'), submit();
}

if(param('domain'))
{
my $d=param('domain');

$d=~/.*(\..*)$/;
$true=0;
foreach(@allowedDomains)
{
if($1 eq $_)
{
$true=1;
}
}
unless($true){
print h1("sorry, we do not allow $1");
exit};

open NAMES, $dfile;

while(<NAMES>)
{
if($_=~/$d/i)
{
print h1('sorry that is taken');
exit;
}
}
close NAMES;        

open NAMES, ">>$dfile";
print NAMES param('domain') . "\n";
close NAMES;
print "done, hit back button and reload prev. page";
}  

                   
Bob
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
I starting with php 12 95
WCAG audit tools 1 53
change home folder path 4 40
How can I do this in Pyhton? 12 75
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logiā€¦
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now