recuperer l'info avec session
Posté : 25 avr. 2007, 02:41
Bonsoir ,
J'aurai voulu savoir comment recuperer une info d'un formulaire pour qu'il me l'affiche sur la seconde page, je m'explique j'ai un script whois en php pour dire si le nom de domaine et libre ou pas.
Une fois le whois fait par exemple le nom de domaine www.essai.com et libre je voudrait que la personne qui clique sur commander que le nom de domaine s'affiche dans le formulaire.
je ne sais pas si c'est bon j'ai commencer a mettre en haut de ma page
http://xxxxx.com/commander_domaine.php?domaine=essai&ext=fr
Se qui et en gras le nom de domaine qui et libre.
Je ne sais pas si j'explique bien j'essaye de faire de mon mieux je suis qu'un noob
je vous montre le code whois au cas ou vous en aurez besoin

J'aurai voulu savoir comment recuperer une info d'un formulaire pour qu'il me l'affiche sur la seconde page, je m'explique j'ai un script whois en php pour dire si le nom de domaine et libre ou pas.
Une fois le whois fait par exemple le nom de domaine www.essai.com et libre je voudrait que la personne qui clique sur commander que le nom de domaine s'affiche dans le formulaire.
je ne sais pas si c'est bon j'ai commencer a mettre en haut de ma page
<?php
session_start();
?>
Ensuite je bloque j'ai deja vu sur un site l'url http://xxxxx.com/commander_domaine.php?domaine=essai&ext=fr
Se qui et en gras le nom de domaine qui et libre.
Je ne sais pas si j'explique bien j'essaye de faire de mon mieux je suis qu'un noob
je vous montre le code whois au cas ou vous en aurez besoin
<?php
class Whois_domain {
var $possible_tlds;
var $whois_server;
var $free_string;
var $whois_param;
var $domain;
var $tld;
var $compl_domain;
var $full_info;
var $msg;
var $info;
var $os_system = "linux"; // switch between "linux" and "win"
function Whois_domain() {
$this->info = "";
$this->msg = "";
}
function process() {
if ($this->create_domain()) {
if ($this->full_info == "yes") {
$this->get_domain_info();
} else {
if ($this->check_only() == 1) {
$this->msg = "<img src='valider.jpg'> Le nom de domaine: <b>".$this->compl_domain."</b> <font color='#008000'>est disponible</font>.<br><form action='commander_domaine.php' method='post'><input src='commander.jpg' type='submit'></form>";
return true;
} elseif ($this->check_only() == 0) {
$this->msg = "<img src='erreur.jpg'> Le nom de domaine: <b>".$this->compl_domain."</b> <font color='#FF0000'>est indisponible</font>.";
return false;
} else {
$this->msg = "There was something wrong, try it again.";
}
}
} else {
$this->msg = "Only letters, numbers and hyphens (-) are valid!";
}
}
function check_entry() {
if (preg_match("/^([a-z0-9]+(\-?[a-z0-9]*)){2,63}$/i", $this->domain)) {
return true;
} else {
return false;
}
}
function create_tld_select() {
$menu = "<select name=\"tld\" style=\"margin-left:0;\">\n";
foreach ($this->possible_tlds as $val) {
$menu .= " <option value=\"".$val."\"";
$menu .= (isset($_POST['tld']) && $_POST['tld'] == $val) ? " selected=\"selected\">" : ">";
$menu .= $val."</option>\n";
}
$menu .= "</select>\n";
return $menu;
}
function create_domain() {
if ($this->check_entry()) {
$this->domain = strtolower($this->domain);
$this->compl_domain = $this->domain.".".$this->tld;
return true;
} else {
return false;
}
}
function check_only() {
$data = $this->get_whois_data();
if (is_array($data)) {
$found = 0;
foreach ($data as $val) {
if (eregi($this->free_string, $val)) {
$found = 1;
}
}
return $found;
} else {
$this->msg = "Error, please try it again.";
}
}
function get_domain_info() {
if ($this->create_domain()) {
$data = ($this->tld == "nl") ? $this->get_whois_data(true) : $this->get_whois_data();
if (is_array($data)) {
foreach ($data as $val) {
if (eregi($this->free_string, $val)) {
$this->msg = "Le nom de domaine: <b>".$this->compl_domain."</b> is free.";
$this->info = "";
break;
}
$this->info .= $val;
}
} else {
$this->msg = "Error, please try it again.";
}
} else {
$this->msg = "Only letters, numbers and hyphens (-) are valid!";
}
}
function get_whois_data($empty_param = false) {
// the parameter is new since version 1.20 and is used for .nl (dutch) domains only
if ($empty_param) {
$this->whois_param = "";
}
if ($this->tld == "de") $this->os_system = "win"; // this tld must be queried with fsock otherwise it will not work
if ($this->os_system == "win") {
$connection = @fsockopen($this->whois_server, 43);
if (!$connection) {
unset($connection);
$this->msg = "Can't connect to the server!";
return;
} else {
sleep(2);
fputs($connection, $this->whois_param.$this->compl_domain."\r\n");
while (!feof($connection)) {
$buffer[] = fgets($connection, 4096);
}
fclose($connection);
}
} else {
$string = "whois -h ".$this->whois_server." \"".$this->whois_param.$this->compl_domain."\"";
$string = str_replace (";", "", $string).";";
exec($string, $buffer);
}
if (isset($buffer)) {
//print_r($buffer);
return $buffer;
} else {
$this->msg = "Can't retrieve data from the server!";
}
}
}
?>
Merci a vous