begin process at 2010 02 10 14:58:08
  Trouver un code source :
 
dans
 
Accueil > Forum > 

PHP

 > 

Base de données

 > 

MySQL

 > 

Help


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Help

mercredi 18 juin 2008 à 09:54:58 | Help

gegenational

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

/*---------------------- Initialize variables ----------------------------*/

// Final Action the script will perform, one of: redirect|close|back|<empty>
$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');

// Required vars
$required = array();


/*------------------------ Start script ------------------------------*/

// Check referrer
if (!_check_referrer()) error("You are sending your webform from an invalid location.");

// Check required vars
if (!_check_required()) error("Please fill all the required fields.");

// Make paranoic spam check if wanted
if ($paranoic_check) _anti_spam();

// Everything ok, send mails

// Auto Respond Message
auto_respond();

// Admin Mail
send_mail();

// End Function
end_html();

// Exit
exit(1);

/*----------------------------------------------------------------------------*/


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";
   
    foreach ($vars as $v) {
        if (!isset($_REQUEST[$v])) continue;
        $t .= str_replace("_", " ", $v) .": ";
        if (is_array($_REQUEST[$v])) {
            $t .= join(', ', $_REQUEST[$v]);
        } else {
            $t .= $_REQUEST[$v];
        }
        $t .= "\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";
        }
    }
   
    if (isset($_REQUEST[$email_var])) {
        $from = $_REQUEST[$email_var];
    } else {
        $from = $report_to;
    }
   
    // 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>
    <body bgcolor='#ffffff' text='#000000' link='#0000ff' vlink='#800080' alink='#ff0000'>
    <center><h1>Error!</h1></center>
    <table align='center' width='70%'>
    <tr>
    <td>
        <b>We are sorry</b> but we encountered an error in your form submission:
        <center><pre>ERROR: $error</pre></center>
        <p>Please click on the &quot;Back&quot; button in your browser
        or click <a href='javascript:history.back(1);'>here</a> to try again.</p>
        <p>&nbsp;</p>
    </td>
    </tr>
    </table>
    </body>
    </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 "
                <h1>Thank You</h1>
                Your information was received correctly.
            ";
        }
       
    } elseif ($final_action == "close") {
        print "
            <html>
            <head>
            </head>
            <body onload='window.close();'>
            </body>
            </html>
        ";
    } elseif ($final_action == "back") {
        print "
            <html>
            <head>
            </head>
            <body onload=\"history.go('-2');\">
            </body>
            </html>
        ";
    } else {
        print "
            <h1>Thank You</h1>
            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
mercredi 18 juin 2008 à 12:22:32 | Re : Help

jack

Administrateur CodeS-SourceS
Réponse acceptée !
Salut
Pas de rapport avec VB.
Question déplacée dans vers le site dédié au PHP

Vala
Jack, MVP VB
NB : Je ne répondrai pas aux messages privés

Le savoir est la seule matière qui s'accroit quand on la partage (Socrate)


Cette discussion est classée dans : email, to, auto, if, respond


Répondre à ce message

Sujets en rapport avec ce message

aidez moi pb avec email !! [ par anisbs ] Salut je suis débutant en phpje commence a essayer quelques trucs mais la fonction mail ne fonctionne pas Il me sort un truc comme :Warning: mail(): email [ par henri12 ] salut j ai mis une fausse adresse j ai essayer if((mail($email, $objet, $contenu, "From: ".$from))==false){ echo $email; l email n est pas envoyer Envoyer des donné à un code [ par slurp9562 ] Bonjour.J'ai récupéré un code PHP suivant:$from_name = "Mr. Anonymous"; <br / Formulaire mail [ par L42RY ] Bonjour à tous ! Merci d'avoir cliqué sur mon topic, car je suis dans la mouise xD. Mon problème vient de ce formulaire mail que j'ai récupéré sur le Problème de formulaire mail :( [ par L42RY ] Bonjour à tous ! Tout d'abord, merci d'avoir pris le temps de cliquer sur mon post. J'ai créé ce dernier car j'ai un petit problème avec un formulaire Problème de Session avec base mysql [ par nooTe91 ] Bonjour,j'ai un petit problème avec les variables de sessions. J'ai déja fait des essais avec des variables et constantes en session avec le tutorial contact2 [ par nicomilville ] bonjour voici mon code ://Dans la ligne qui suit, remplacer webmaster@domaine.tld par l'adresse email du webmaster, à laquelle les messages devront êt easyphp server [ par domi81 ] Bonjour,J'ai installé easyphp 3.0Je voudrais renseigné une base de données avec un formulaire mais ce message d'erreur apparait : Objet non trouvé!L'U Fonction vérification de doublons [ par kontas ] Bonjour a tous ! J'ai un script qui va verifier coté serveur mes info provenant d'un formulaire. seulement j'ai voulu r'ajouter un systeme permetant valider un captcha [ par philclimb ] Bonjour;J'ai réaliser un formulaire de mail que je veux placer dans la page "contact" de mon site.Pour éviter les vilains spams j'ai placé un captcha,


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,811 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales