whois lookup need help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
faza
Forum Newbie
Posts: 9
Joined: Tue Jun 22, 2010 4:28 pm

whois lookup need help

Post by faza »

Hi
Im a newbie developer and am trying to setup a simple page for a whoislookup query
I need it to show results on another page and am struggling as i cant find any decent explainations on the net ALL HELP will be GREATLY appreciated and any direction as to good sources of material that could help me understand this better would be awesome THanks -

Heres my code so far

whois.php - page

Code: Select all

<php>
<html>
<body>
<h1 style="text-align:center;">Multiple whois lookup query</h1></center>
<P style="text-align:center;">This app is used to check for available FQDN's.</P>
<P style="text-align:center;">PLease enter one suggested domain name per field.</P>

<center><form  action = "results.php" method= "post">
	<input type="text" name="Domainname"/></br>
	<input type="text" name="Domainname1"/></br>
	<input type="text" name="Domainname2"/></br>
	<input type="text" name="Domainname3"/></br>
	<input type="text" name="Domainname4"/></br>
	<input type="text" name="Domainname5"/></br>
	<input type="text" name="Domainname6"/></br>
	<input type="text" name="Domainname7"/></br>
	<input type="text" name="Domainname8"/></br>
	<input type="text" name="Domainname9"/></br>
	<input type="text" name="Domainname10"/></br>
	</br>
	<input type="submit" value="Check availability"/> 
	</form></center>

	
	<?php
	$domain = $_REQUEST['domain'];
	$output = shell_exec(“whois $domain”);
	echo $output;
	?>
</font>
</body>
</html>
</php>


Results.php page

<?php 
	
	$result = shell_exec('whois ' . $_POST["Domainname" ] )
	$tidy_result = str_replace("\n","<br>",$result);
	echo $tidy_result;
	
	

?>!<br />
<?php echo $_POST["Domainname1"]; ?>!<br />
<?php echo $_POST["Domainname2"]; ?>!<br />
<?php echo $_POST["Domainname3"]; ?>!<br />
<?php echo $_POST["Domainname4"]; ?>!<br />
<?php echo $_POST["Domainname5"]; ?>!<br />
<?php echo $_POST["Domainname6"]; ?>!<br />
<?php echo $_POST["Domainname7"]; ?>!<br />
<?php echo $_POST["Domainname8"]; ?>!<br />
<?php echo $_POST["Domainname9"]; ?>!<br />	
<?php echo $_POST["Domainname10"]; ?>!<br />
Last edited by Benjamin on Fri Jul 02, 2010 12:07 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: whois lookup need help

Post by Jade »

You don't have a variable named $_POST["Domainname"]. The form is only going to $_POST the names of the fields that were on your whois.php page ie Domainname1, Domainname2, Domainname3.

Code: Select all

echo str_replace("\n","<br/>",shell_exec('whois ' . $_POST["Domainname1" ] ));
faza
Forum Newbie
Posts: 9
Joined: Tue Jun 22, 2010 4:28 pm

Re: whois lookup need help

Post by faza »

Yeh the first box on the whois page is domainname then the scond is domainname 1
I have since changed this to a textarea
I need to know how i can break up the results and have display it neatly within a table with different sections
Thanks
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: whois lookup need help

Post by Jade »

You'll have to parse the results in order to display it however you want to. There's also this function that may help: http://php.net/manual/en/function.nl2br.php
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: whois lookup need help

Post by AbraCadaver »

faza wrote:Yeh the first box on the whois page is domainname then the scond is domainname 1
I have since changed this to a textarea
I need to know how i can break up the results and have display it neatly within a table with different sections
Thanks
Probably something like:

Code: Select all

$domains = explode(PHP_EOL, $_POST['domains']);

foreach($domains as $domain) {
   echo $domain;
}
Do not exec() user input. Users can execute some very nasty and dangerous stuff on your server. Look into http://us.php.net/manual/en/function.escapeshellarg.php
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply