gegenational
Messages postés2Date d'inscriptionmardi 17 juin 2008StatutMembreDernière intervention19 juin 2008
-
18 juin 2008 à 09:54
cs_Jack
Messages postés14006Date d'inscriptionsamedi 29 décembre 2001StatutModérateurDernière intervention28 août 2015
-
18 juin 2008 à 12:22
Bonjour a tous,
je souhaite developer la gestion d'une compagnie virtuelle avec en base de donnée mysql mais j'ai un gros bloquage.
J'ai fais ma page en html et je voudrais savoir faire comment mettre en relation les donnee qu'on mets dans le dossier html jusqu'a la Db du moin est ce possible
En bref.
voila mon fichier php et si qq peux m'aider a mettre en relation ces donnees a ma db et surtout creer ma db je serais le plus heureux
<?php
// Final Action the script will perform, one of: redirect|close|back|
$final_action = 'redirect';
// Redirection URL, e.g. http://www.google.com, start with "http://...". Valid if $final_action is 'redirect'
$end_html = 'http://';
// Set to 1 if you want a report of environment vars
$environment = 1;
// Perform an extra spam check? set to 0 or 1
$paranoic_check = 1;
// Send auto respond?
$auto_respond = 0;
// Auto Respond Subject
$auto_respond_subject = 'NOVALID';
// Auto Respond Message
$auto_respond_message = 'NOVALID';
// Name of the var with the user's mail
$email_var = "NOVALID";
// Where to send the admin email
$report_to = 'samu64a@hotmail.fr';
// Subject for the admin email
$subject = "gestionVA";
// Allowed domains for form submissions
$ref = array('mydomain.com','myotherdomain.com','www.paradise-airlines.com');
// Name of all the vars we want to receive
$vars = array('Nom_compagnie','type_dappareil','Model_dappareil','Aéroport_compagnie','Identification_Compagnie','Contrat_Entretien','Type_de_Vols','Prêt_Banque','Remboursement_Banque','Départ_','Arrivée');
function _check_referrer() {
// check that the submission was made from a valid domain defined on the global $ref array
global $ref;
$requested_from = $_SERVER['HTTP_REFERER'];
if ($requested_from == ''){
error("Unable to find referrer");
}
$status_ref = 0;
foreach ($ref as $r){
if (preg_match("/$r/", $requested_from)) {
$status_ref = 1;
break;
}
}
return $status_ref;
} // function _check_referrer
function _check_required() {
// check that all required variables have been submitted
global $required;
$error_status = 1;
foreach ($required as $r) {
if (!isset($_REQUEST{$r})) {
$error_status = 0;
break;
}
}
return $error_status;
} // function _check_required
function _anti_spam() {
// check all input variables for CC:, BCC:, charset=iso and Content-Type: substrings
foreach ($_REQUEST as $v => $val) {
// DETECT CC: or BCC:
if (preg_match("/(?:B)?CC\:/im", $val)) {
error("A SPAM attempt was detected.");
}
// DETECT charset
if (preg_match("/charset\=iso/im", $val)) {
error("A SPAM attempt was detected.");
}
// DETECT content/type
if (preg_match("/Content\-Type/im", $val)) {
error("A SPAM attempt was detected.");
}
}
} // function _anti_spam
function auto_respond() {
//If there is an $email_var defined and $auto_respond is set to 1 we send a message
global $email_var, $report_to, $vars, $auto_respond, $auto_respond_subject, $auto_respond_message;
if (isset($_REQUEST[$email_var]) and $auto_respond and is_email($_REQUEST[$email_var])) {
# filter the $auto_respond_message and substite the variables with their values
# The variables in the message will be in the form of: $VAR_NAMEs
foreach ($vars as $v) {
$auto_respond_message = str_replace("\$$v", $_REQUEST[$v], $auto_respond_message);
}
$auto_respond_message = preg_replace("/\\n/", "\n", $auto_respond_message);
// set FROM:
$headers = "From: " . $report_to . "\r\n";
// some SMTP servers require this ini_set to handle FROM: correctly:
@ini_set('sendmail_from', $report_to);
if (!mail($_REQUEST[$email_var], $auto_respond_subject, $auto_respond_message, $headers)) {
die("Cannot send email to " . $_REQUEST[$email_var]);
}
}
} // function auto_respond
function send_mail() {
// In this function we build a new mail message for the admin.
// The body of the message will have all the vars submited by the user.
// The global array @vars has the names of the expected vars
global $email_var, $report_to, $vars, $subject, $environment;
$t = '';
$t .= "Result of the webform sent on: " . date("F j, Y, g:i a") . "\n";
$t .= "\n";
// If $environment is set to 1 then attach a report of the most common environment variables:
if ($environment) {
$t .= "-------------------\n";
foreach ( array(
'HTTP_USER_AGENT' => 'UserAgent',
'REMOTE_ADDR' => 'IP',
'REMOTE_HOST' => 'Host',
'HTTP_REFERER' => 'Referer',
'HTTP_VIA' => 'Via'
) as $ev => $evv) {
if (isset($_SERVER[$ev])) $t .= "$evv: " . $_SERVER[$ev] . "\n";
}
}
// set FROM:
$headers = "From: " . $from . "\r\n";
// some SMTP servers require this ini_set to handle FROM: correctly:
@ini_set('sendmail_from', $from);
if (!mail($report_to, $subject, $t, $headers)) {
die("Cannot send email to " . $report_to);
}
} // function send_mail()
function error($error) {
// to display a customized error page and exit the script
print "
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Error!</title>
<STYLE TYPE='text/css'>
BODY{
font-family:verdana,arial,helvetica;
font-size:9pt;
color:black;
}
H1{ color:red; }
</STYLE>
</head>
<center>Error!
</center>
----
We are sorry but we encountered an error in your form submission:
<center>ERROR: $error
</center>
Please click on the "Back" button in your browser
or click here to try again.
,
</html>";
exit(0);
} // function error
function end_html() {
// make the final action depending of the value of $final_action
global $final_action, $end_html;
if ($final_action == "redirect") {
if($end_html){
header("Location: $end_html");
} else {
print "
Thank You
Your information was received correctly.
";
}
} // function end_html
function is_email($email) {
// checks if $email is a well-formed email
return (preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email));
}
?>
Merci d'avance et si vous pouvez directement m'envoyer un mail ca serai mieux merci
mon msn samu64a@hotmail.fr