Page 1 of 1

whois lookup need help

Posted: Fri Jul 02, 2010 10:19 am
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 />

Re: whois lookup need help

Posted: Fri Jul 02, 2010 10:50 am
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" ] ));

Re: whois lookup need help

Posted: Fri Jul 02, 2010 11:23 am
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

Re: whois lookup need help

Posted: Fri Jul 02, 2010 11:32 am
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

Re: whois lookup need help

Posted: Fri Jul 02, 2010 12:32 pm
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