<div class="cfg-element-container"> <label class="cfg-label" id="cfg-element-35-7-label" ><span class="cfg-label-value">Nom Prénom</span><span class="cfg-required">*</span></label> <div class="cfg-element-set" id="cfg-element-35-7-set" > <div class="cfg-element-content"> <input type="text" class="cfg-type-text cfg-form-value " name="cfg-element-35-7" id="cfg-element-35-7" />
<?php if (isset($_POST["cfg-element-35-7"]) && !empty($_POST["cfg-element-35-7"])) {$nomtobase=$_POST["cfg-element-35-7"];} else {$nomtobase="empty";} // à partir de là on ne travaille plus qu'avec $nomtobase if ($nomtobase==='empty') { print "champ 'cfg-element-35-7' non soumis via formulaire";exit;} // traitement base $db=mysql_connect("mabase.eu.mysql", "mabase_eu", "*****");// ok mysql_select_db("mabase_eu.mysql", $db);// ok //$sql="INSERT INTO matable (nomprenom) VALUES ('$nomtobase')"; $sql="INSERT INTO confid (nomprenom) VALUES('".$nomtobase."')"; mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error()); // insertion table echo var_dump($nomtobase);//affiche NULL mysql_close(); ?> </div> </div> <div class="cfg-clear"></div>
<code> jQuery(function(){ jQuery('#cfg-contactform-35 .cfg-submit').click(function(){ var formcontainer = jQuery(this).closest('.cfg-contactform'); var loading = formcontainer.find('.cfg-loading'); loading.show(); var submit_btn = jQuery(this); submit_btn.hide(); formcontainer.find('.cfg-errormessage').hide().remove(); var form_value_array = Array(); var radio_value = Array(); var checkbox_value = Array(); var selectmultiple_value = Array(); var deleteuploadedfile_value = Array(); formcontainer.find('.cfg-form-value').each(function() { var elementlabel = jQuery(this).closest('.cfg-element-container').find('.cfg-label-value'); var elementlabel_id = elementlabel.closest('label').attr('id'); var elementlabel_value = elementlabel.html(); // catch uploads if(jQuery(this).hasClass('cfg-uploadfilename')) { var key = jQuery(this).prop('name'); var value = jQuery.trim(jQuery(this).val()); var deletefile = jQuery(this).closest('.cfg-element-content').find('.cfg-uploaddeletefile').val(); form_value_array.push({'element_id': key, 'element_value': value, 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value, 'element_type':'upload', 'filename':value, 'element_type':'upload', 'deletefile':deletefile}); } ......</code>
Ou alors, l'input et son name="cfg-element-35-7" ne se lançe qu'après le submit du formulaire qui m'envoie un mail de contactIl y a bien un "submit" quelque part...et finalement le code javascript que tu nous collé pourrait correspondre (et dans ce cas...dans le reste du code tu as surement de l'ajax )...
jQuery('#cfg-contactform-35 .cfg-submit').click(function()
jQuery(function(){ jQuery('#cfg-contactform-35 .cfg-submit').click(function(){ // Ajout d'un ALERT... var cfg-element-35-7 = $("#cfg-element-35-7").val(); alert("cfg-element-35-7 =" + cfg-element-35-7); // Le reste du code.... var formcontainer = jQuery(this).closest('.cfg-contactform'); var loading = formcontainer.find('.cfg-loading');
<?php //*****************************************************// // Connexion à la BDD (l'ideal etant de le mettre dans fichier à part) // //*****************************************************// $db=mysql_connect("mabase.eu.mysql", "mabase_eu", "*****");// ok mysql_select_db("mabase_eu.mysql", $db);// ok //----------------------------------------------------------- // Print de POST pour voir si ton formulaire fonctionne... echo " POST =<br>"; print_r($_POST); //----------------------------------------------------------- // Utilisation de l'écriture Ternaire au lieu des IF / ELSE.. $nomtobase = isset($_POST["cfg-element-35-7") && !empty($_POST["cfg-element-35-7")?$_POST["cfg-element-35-7"]:NULL; //----------------------------------------------------------- // On vérifieque $nomtobase n'est pas vide avant de continuer... if($nomtobase){ $sql="INSERT INTO confid (nomprenom) VALUES('".$nomtobase."')"; // insertion dans la table $res = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error()); // echo var_dump($nomtobase);//affiche NULL // Ou tu fais un ECHO ... ou un var_dump .. pas les deux ! var_dump($nomtobase); }else{ echo "<br> nombase est vide !<br>"; } mysql_close(); ?>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question<div class="cfg-element-container">
<label class="cfg-label" id="cfg-element-35-7-label" ><span class="cfg-label-value">Nom Prénom</span><span class="cfg-required">*</span></label>
<div class="cfg-element-set" id="cfg-element-35-7-set" >
<div class="cfg-element-content">
<input type="text" class="cfg-type-text cfg-form-value " name="cfg-element-35-7" id="cfg-element-35-7" />
<?php
// mon code php ci dessous
?>
</div>
</div>
<div class="cfg-clear"></div>
</div>
</code>
<code><?php // Print de POST pour voir si formulaire ok echo " POST =<br>"; print_r($_POST); $nomtobase = isset($_POST["cfg-element-35-7"]) && !empty($_POST["cfg-element-35-7"])?$_POST["cfg-element-35-7"]:NULL; if($nomtobase) { // connexion $db=mysql_connect("mabase.eu.mysql", "mabase_eu", "*****");// ok mysql_select_db("mabase._eu.mysql", $db);// ok // insertion $sql="INSERT INTO matable (nomprenom) VALUES('".$nomtobase."')"; $res = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error()); //vérification var_dump($nomtobase); } else { echo "<br> nombase est vide !<br>"; } mysql_close(); ?>
Affichage Ihm : POST =Ton souci vient de la transmission de tes données entre ton formulaire HTML et ton code php...
Array ( )
<form method="post" action="LapagePhp.php"> <!-- LE RESTE DE TON CODE --> </form>
j'ai appliqué les correctifs, pour plus de lisbilité tu trouveras ci dessous le code "reformaté" :Au passage.. si tu veux vraiment bien formaté ton HTML.. n'hésites pas à faire des retours à la ligne ..
<div class="cfg-element-container"> <label class="cfg-label" id="cfg-element-35-7-label" > <span class="cfg-label-value">Nom Prénom</span> <span class="cfg-required">*</span> </label> <div class="cfg-element-set" id="cfg-element-35-7-set" > <div class="cfg-element-content"> <input type="text" class="cfg-type-text cfg-form-value " name="cfg-element-35-7" id="cfg-element-35-7" /> <?php // mon code php ci dessous ?> </div> </div> <div class="cfg-clear"></div> </div>
<code><?php session_start(); require("authentific.php"); if(Authentific::isLogged()){ } else { header('Location: login.php'); } ?></code>
Et ce fichier "d'enregistrement" doit avoir une requête mysql en JS ? c'est toujours ça ?Oulllaaaa...
Mais ou est passé le php ?Une fois que tu auras lu le lien que je t'ai donné.. tu verras que ,en gros,...
(onSubmitt) = Se produit lorsque l'utilisateur clique sur le bouton de soumission d'un formulaire (le bouton qui permet d'envoyer le formulaire), ça devrait marcher..Ca c'est valable.. QUAND tu as des balises <form ... > .... </form>
<div class="cfg-element-container">
<div class="cfg-element-set" id="cfg-element-35-32-set" >
<div class="cfg-element-content">
<input type="submit" class="cfg-submit " name="cfg-element-35-32"
id="cfg-element-35-32" value="Envoi du message" />
</div>
</div>
</div>
<code>jQuery(function(){ /* if(!jQuery.isFunction(jQuery.fn.on)){ var jquery_version_error_message = 'The contact form requires jQuery 1.7.2 to work properly.<br />jQuery '+jQuery().jquery+' is loaded.'; jQuery('.cfg-contactform').prepend('<p style="color:#FF0000">'+jquery_version_error_message+'</p>'); } */ jQuery('#cfg-contactform-35 .cfg-uploadfilename').val(''); // FF may keep the file name in the cfg-uploadfilename input after submitting and refreshing the page jQuery('#cfg-contactform-35 .cfg-captcha-refresh').click(function(){ $('#cfg-contactform-35 .cfg-captcha-img').attr('src','cfg-contactform-35/inc/captcha.php?r=' + Math.random()); }); jQuery('#cfg-contactform-35 .cfg-submit').click(function() { // Ajout d'un ALERT... var cfg-element-35-7 = $("#cfg-element-35-7").val(); alert("cfg-element-35-7 =" + cfg-element-35-7); // fin ajout code de Jordane var formcontainer = jQuery(this).closest('.cfg-contactform'); var loading = formcontainer.find('.cfg-loading'); var formcontainer = jQuery(this).closest('.cfg-contactform'); var loading = formcontainer.find('.cfg-loading'); loading.show(); var submit_btn = jQuery(this); submit_btn.hide(); formcontainer.find('.cfg-errormessage').hide().remove(); var form_value_array = Array(); var radio_value = Array(); var checkbox_value = Array(); var selectmultiple_value = Array(); var deleteuploadedfile_value = Array(); formcontainer.find('.cfg-form-value').each(function() { var elementlabel = jQuery(this).closest('.cfg-element-container').find('.cfg-label-value'); var elementlabel_id = elementlabel.closest('label').attr('id'); var elementlabel_value = elementlabel.html(); // catch uploads if(jQuery(this).hasClass('cfg-uploadfilename')) {........} // catch input text values, textarea values, select values if(jQuery(this).is('.cfg-type-text, .cfg-type-textarea, .cfg-type-select')) {.......} // catch radiobutton values if(jQuery(this).is(':radio')) {....} // catch checkbox values if(jQuery(this).is(':checkbox')) {..} // catch multiple select values if(jQuery(this).hasClass('cfg-type-selectmultiple')) {....} // catch time values if(jQuery(this).hasClass('cfg-type-time')) {.....} }); // catch list of uploaded files to delete formcontainer.find('.cfg-deleteuploadedfile').each(function() {..}); var captcha_img; var captcha_input; if(formcontainer.find('.cfg-captcha-img').length) {...} // console.log(deleteuploadedfile_value); // console.log(form_value_array); jQuery.post('cfg-contactform-35/inc/form-validation.php', {.... }, function(data) {....} /* end function data */ ); /* end jQuery.post */ }); /* end click submit */ // DELETE UPLOADED FILE jQuery('body').on('click', '#cfg-contactform-35 .cfg-deleteupload', function() {....}); });</code>
jQuery.post('cfg-contactform-35/inc/form-validation.php',
<code><!-- NOM PRENOM --> <div class="cfg-element-container"> <label class="cfg-label" id="cfg-element-35-7-label" ><span class="cfg-label-value">Nom Prénom</span><span class="cfg-required">*</span></label> <div class="cfg-element-set" id="cfg-element-35-7-set" > <div class="cfg-element-content"> <input type="text" class="cfg-type-text cfg-form-value " name="cfg-element-35-7" id="cfg-element-35-7" /> </div> </div> <div class="cfg-clear"></div> </div></code>
<code>// catch input text values, textarea values, select values if(jQuery(this).is('.cfg-type-text, .cfg-type-textarea, .cfg-type-select')) { var key = jQuery(this).prop('id'); var value = jQuery('#'+jQuery(this).prop('id')).val(); form_value_array.push({'element_id': key, 'element_value': value, 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value}); }</code>
<code>// catch uploads if(jQuery(this).hasClass('cfg-uploadfilename')) {........} // catch input text values, textarea values, select values if(jQuery(this).is('.cfg-type-text, .cfg-type-textarea, .cfg-type-select')) {.......} // catch radiobutton values if(jQuery(this).is(':radio')) {....} // catch checkbox values if(jQuery(this).is(':checkbox')) {..} // catch multiple select values if(jQuery(this).hasClass('cfg-type-selectmultiple')) {....} // catch time values if(jQuery(this).hasClass('cfg-type-time')) {.....}</code>
Dans le script php "form-validation.php" traiter leur traitement vers la BDDC'est DANS CE FICHIER que tu dois ajouter ton code d'insert en BDD :
Je ne viens pas souvent sur le forum, mais la dernière fois c'était encore toi qui m'avait dépanné, et je vois que tu est très sollicité(e)Ben.. si je peux aider....^^
Bien sincèrement, Mille fois merci Jordane , continue.."continue" ... A être sollicité ou à t'aider ? ... :-)
je ne sais pas comment il faut clore le sujetEn cliquant sur le lien : Marquer comme résolu ( en haut, sous le titre de ta question )
<code>// On établit la connection try { $db=mysql_connect("*******.eu.mysql", "******_eu", "*********");// ok mysql_select_db("******._eu.mysql", $db);// ok } catch ( Exception $e ) { echo "Connection à MySQL impossible : ", $e->getMessage(); die(); } try { // entrée données mysql_select_db("**********_eu.mysql", $db); $sql="INSERT INTO matable (nomprenom) VALUES ('$????????????')"; $sql="INSERT INTO matable (email) VALUES ('$?????????l')"; $sql="INSERT INTO matable (telephone) VALUES ('$???????')"; $sql="INSERT INTO matable (typecontact) VALUES ('$???????')"; } catch ( Exception $e ) { echo "Connection à MySQL impossible : ", $e->getMessage(); die(); }</code>
<code>jQuery(function(){ /* if(!jQuery.isFunction(jQuery.fn.on)){ var jquery_version_error_message = 'The contact form requires jQuery 1.7.2 to work properly.<br />jQuery '+jQuery().jquery+' is loaded.'; jQuery('.cfg-contactform').prepend('<p style="color:#FF0000">'+jquery_version_error_message+'</p>'); } */ jQuery('#cfg-contactform-35 .cfg-uploadfilename').val(''); // FF may keep the file name in the cfg-uploadfilename input after submitting and refreshing the page jQuery('#cfg-contactform-35 .cfg-captcha-refresh').click(function(){ $('#cfg-contactform-35 .cfg-captcha-img').attr('src','cfg-contactform-35/inc/captcha.php?r=' + Math.random()); }); //****************************** click fonction submit jQuery('#cfg-contactform-35 .cfg-submit').click(function(){ //****************************************************************************************** var formcontainer = jQuery(this).closest('.cfg-contactform'); var loading = formcontainer.find('.cfg-loading'); loading.show(); var submit_btn = jQuery(this); submit_btn.hide(); formcontainer.find('.cfg-errormessage').hide().remove(); var form_value_array = Array(); var radio_value = Array(); var checkbox_value = Array(); var selectmultiple_value = Array(); var deleteuploadedfile_value = Array(); formcontainer.find('.cfg-form-value').each(function() { var elementlabel = jQuery(this).closest('.cfg-element-container').find('.cfg-label-value'); var elementlabel_id = elementlabel.closest('label').attr('id'); var elementlabel_value = elementlabel.html(); //************************************upload // catch uploads if(jQuery(this).hasClass('cfg-uploadfilename')) { var key = jQuery(this).prop('name'); var value = jQuery.trim(jQuery(this).val()); var deletefile = jQuery(this).closest('.cfg-element-content').find('.cfg-uploaddeletefile').val(); form_value_array.push({'element_id': key, 'element_value': value, 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value, 'element_type':'upload', 'filename':value, 'element_type':'upload', 'deletefile':deletefile}); } //************************************text // catch input text values, textarea values, select values if(jQuery(this).is('.cfg-type-text, .cfg-type-textarea, .cfg-type-select')) { var key = jQuery(this).prop('id'); var value = jQuery('#'+jQuery(this).prop('id')).val(); form_value_array.push({'element_id': key, 'element_value': value, 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value}); } //************************************radio boutons // catch radiobutton values if(jQuery(this).is(':radio')) { var key = jQuery(this).prop('name'); var value = jQuery(this).val(); var check_index_radio_form_value = form_value_array.length+1; if(jQuery(this).is(':checked')){ form_value_array.push({'element_id': key, 'element_value': value, 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value}); radio_value[key] = value; } if( jQuery(this).is( jQuery(this).closest('.cfg-element-container').find('input[name='+key+']:last')) ) { if(!radio_value[key]){ form_value_array.push({'element_id': key, 'element_value': '', 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value}); } } } //***********************************checkbox******************************************* // catch checkbox values if(jQuery(this).is(':checkbox')) { var key = jQuery(this).prop('name'); var value = jQuery(this).val(); if(jQuery(this).is(':checked')) { form_value_array.push({'element_id': key, 'element_value': value, 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value}); checkbox_value[key] = value; } if( jQuery(this).is(jQuery(this).closest('.cfg-element-container').find('input[name='+key+']:last'))) { // we are at the last checkbox, and the checkbox[name] array value is still empty => insert fieldname: '' in the notification if(!checkbox_value[key]) { form_value_array.push({'element_id': key, 'element_value': '', 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value}); } } } // catch multiple select values if(jQuery(this).hasClass('cfg-type-selectmultiple')) { var key = jQuery(this).prop('name'); // must be placed here, not in each() or php will return Undefined index: element_id jQuery(this).find('option').each(function() { var value = jQuery(this).val(); if(jQuery(this).is(':selected')) { form_value_array.push({'element_id': key, 'element_value': value, 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value}); selectmultiple_value[key] = value; } if( jQuery(this).is( jQuery(this).closest('.cfg-type-selectmultiple').find('option:last')) ) { // we are at the last option, and the selectmultiple[name] array value is still empty => insert fieldname: '' in the notification if(!selectmultiple_value[key]) { form_value_array.push({'element_id': key, 'element_value': '', 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value}); } } }); } // catch time values if(jQuery(this).hasClass('cfg-type-time')) { //var key = jQuery(this).find('.cfg-time-hour').prop('name'); var key = jQuery(this).closest('.cfg-element-container').find('.cfg-time-hour').prop('name'); var ampm = jQuery(this).closest('.cfg-element-container').find('.cfg-time-ampm').val(); if(ampm == undefined) ampm = ''; // no quote on undefined var value = jQuery(this).closest('.cfg-element-container').find('.cfg-time-hour').val()+':'+jQuery(this).closest('.cfg-element-container').find('.cfg-time-minute').val()+' '+ampm; form_value_array.push({'element_id': key, 'element_value': value, 'elementlabel_id':elementlabel_id, 'elementlabel_value':elementlabel_value}); } }); //***************************** uploaded files to delet******************************************************************** // catch list of uploaded files to delete formcontainer.find('.cfg-deleteuploadedfile').each(function(){ deleteuploadedfile_value.push(jQuery(this).val()); }); var captcha_img; var captcha_input; if(formcontainer.find('.cfg-captcha-img').length) { captcha_img = 1; captcha_input = formcontainer.find('.cfg-captcha-input').val(); } // console.log(deleteuploadedfile_value); // console.log(form_value_array); // ACTION FORMULAIRE génère le submit ( donc l'envoie en POST vers le fichier PHP : form-validation.php**************** jQuery.post('cfg-contactform-35/inc/form-validation.php', //**************************************************************************************************************** { 'captcha_img':captcha_img, 'captcha_input':captcha_input, 'form_value_array':form_value_array, 'deleteuploadedfile':deleteuploadedfile_value }, function(data) { loading.hide(); data = jQuery.trim(data); // console.log(data); response = jQuery.parseJSON(data); if(response['status'] == 'ok') { if(response['redirect_url']) { window.location.href = response['redirect_url']; } else { validation_message = '<div class="cfg-validationmessage">'+response['message']+'</div>'; formcontainer.find('.cfg-element-container').each(function() { if(!jQuery(this).find('.cfg-title').html()) { jQuery(this).slideUp('fast'); } }); jQuery('html, body').animate({scrollTop:formcontainer.offset().top}, 'fast'); formcontainer.find('.cfg-contactform-content').append(validation_message); } } else { submit_btn.show(); for(var i=0; i<response['message'].length; i++) { var optioncontainer = jQuery('[name*='+response['message'][i]['element_id']+']:first').closest('.cfg-element-content'); jQuery('<div class="cfg-errormessage">'+response['message'][i]['errormessage']+'</div>').prependTo(optioncontainer).fadeIn(); } // scrolls to the first error message jQuery('html,body').animate({scrollTop: jQuery('#'+response['message'][0]['elementlabel_id']).offset().top},'fast'); } } /* end function data */ ); /* end jQuery.post */ }); /* end click submit */ // DELETE UPLOADED FILE jQuery('body').on('click', '#cfg-contactform-35 .cfg-deleteupload', function() { var filename = jQuery(this).closest('.cfg-uploadsuccess-container').find('.cfg-deleteupload-filename').val(); // to add the filename to the list of files to delete // // the .cfg-deleteuploadedfile input can also be added in case of chain upload (handlers.js) jQuery(this).closest('.cfg-element-content').append('<input value="'+filename+'" type="hidden" class="cfg-deleteuploadedfile" />'); // reset the upload input that contains the filename value jQuery(this).closest('.cfg-element-content').find('.cfg-uploadfilename').val(''); // must come last, jQuery(this) is used to access closest elements jQuery(this).closest('.cfg-uploadsuccess-container').remove(); }); });</code>
<code><?php class contactForm{ function contactForm($cfg) { $this->cfg['email_address'] = isset($cfg['email_address'])?$cfg['email_address']:''; // =?UTF-8?B? required to avoid bad character encoding in the From field // é (keeps utf-8 encoding in the file) $this->cfg['email_from'] = (isset($cfg['email_from']) && $cfg['email_from'])?'=?UTF-8?B?'.base64_encode($cfg['email_from']).'?=':$this->cfg['email_address']; $this->cfg['email_address_cc'] = isset($cfg['email_address_cc'])?$cfg['email_address_cc']:''; $this->cfg['email_address_bcc'] = isset($cfg['email_address_bcc'])?$cfg['email_address_bcc']:''; $this->cfg['timezone'] = isset($cfg['timezone'])?$cfg['timezone']:''; $this->cfg['adminnotification_subject'] = isset($cfg['adminnotification_subject'])?$cfg['adminnotification_subject']:''; $this->cfg['usernotification_insertformdata'] = isset($cfg['usernotification_insertformdata'])?$cfg['usernotification_insertformdata']:''; $this->cfg['usernotification_inputid'] = isset($cfg['usernotification_inputid'])?$cfg['usernotification_inputid']:''; $this->cfg['usernotification_subject'] = isset($cfg['usernotification_subject'])?$cfg['usernotification_subject']:''; $this->cfg['usernotification_message'] = isset($cfg['usernotification_message'])?preg_replace('#<br(\s*)/>|<br(\s*)>#i', "\r\n",$cfg['usernotification_message']):''; $this->cfg['form_name'] = isset($cfg['form_name'])?$cfg['form_name']:''; $this->cfg['form_errormessage_captcha'] = isset($cfg['form_errormessage_captcha'])?$cfg['form_errormessage_captcha']:''; $this->cfg['form_errormessage_emptyfield'] = isset($cfg['form_errormessage_emptyfield'])?$cfg['form_errormessage_emptyfield']:''; $this->cfg['form_errormessage_invalidemailaddress'] = isset($cfg['form_errormessage_invalidemailaddress'])?$cfg['form_errormessage_invalidemailaddress']:''; $this->cfg['form_validationmessage'] = isset($cfg['form_validationmessage'])?$cfg['form_validationmessage']:''; $this->cfg['form_redirecturl'] = isset($cfg['form_redirecturl'])?$cfg['form_redirecturl']:''; $this->dash_line = '--------------------------------------------------------------'; $this->mail_content_type_format = 'plaintext'; // html if($this->mail_content_type_format == 'plaintext') { $this->mail_content_type_format_charset = 'Content-type: text/plain; charset=utf-8'; $this->mail_line_break = "\r\n"; } if($this->mail_content_type_format == 'html') { $this->mail_content_type_format_charset = 'Content-type: text/html; charset=utf-8'; $this->mail_line_break = "<br />"; } /** * USER NOTIFICATION MAIL FORMAT */ $this->cfg['usernotification_format'] = isset($cfg['usernotification_format'])?$cfg['usernotification_format']:''; if($this->cfg['usernotification_format'] == 'plaintext') { $this->mail_content_type_format_charset_usernotification = 'Content-type: text/plain; charset=utf-8'; $this->mail_line_break_usernotification = "\r\n"; } if($this->cfg['usernotification_format'] == 'html') { $this->mail_content_type_format_charset_usernotification = 'Content-type: text/html; charset=utf-8'; $this->mail_line_break_usernotification = "<br />"; } $this->merge_post_index = 0; $this->demo = 0; $this->envato_link = 'http://codecanyon.net/item/contact-form-generator/1719810?ref=topstudio'; } function sendMail($param) { $count_files_to_attach = 0; // grab and insert the form URL in the notification message $form_url = (@$_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; if($_SERVER['SERVER_PORT'] != '80') { $form_url .= $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].rawurlencode($_SERVER['SCRIPT_NAME']); } else { $form_url .= $_SERVER['SERVER_NAME'].rawurlencode($_SERVER['SCRIPT_NAME']); } $form_url = str_replace('%2F', '/', $form_url); $form_url_exp = explode('/', $form_url); // remove contactform/inc/form-validation.php $pattern_slash = $form_url_exp[count($form_url_exp)-3].'/'.$form_url_exp[count($form_url_exp)-2].'/'.$form_url_exp[count($form_url_exp)-1]; $form_url = str_replace($pattern_slash, '', $form_url); if($this->cfg['timezone']) { date_default_timezone_set($this->cfg['timezone']); } // g:i A | 01:37 AM // G:i | 13:37 $mail_body = $this->cfg['adminnotification_subject'].': '.@date("F jS, Y, G:i") .$this->mail_line_break.$this->mail_line_break.$this->cfg['form_name'] .$this->mail_line_break.$this->mail_line_break.'Form URL: ' .$this->mail_line_break.$form_url .$this->mail_line_break.$this->dash_line; if($this->merge_post) { foreach($this->merge_post as $value) { if( isset($value['element_type']) && $value['element_type'] == 'upload' && isset($value['filename']) && $value['filename'] ) { if( isset($value['deletefile']) && ($value['deletefile'] == 1 || $value['deletefile'] == 2) ) { $count_files_to_attach++; } $explode_requesturi = explode('/',$_SERVER['REQUEST_URI']); //print_r($explode_requesturi); $explode_requesturi = explode('/',$_SERVER['SCRIPT_NAME']); //print_r($explode_requesturi); $inc_form_validation = $explode_requesturi[count($explode_requesturi)-2].'/'.$explode_requesturi[count($explode_requesturi)-1] ; $install_dir = str_replace($inc_form_validation,'',$_SERVER['SCRIPT_NAME']); $mail_body .= $this->mail_line_break.$this->mail_line_break.$value['elementlabel_value'].': '.$value['element_value']; // No file link if we delete the file after the upload // 1: File Attachment + Download Link // 2: File Attachment Only if( isset($value['deletefile']) && ($value['deletefile'] == 1 || $value['deletefile'] == 3) ) { $mail_body .= $this->mail_line_break .'http://'.$_SERVER['SERVER_NAME'] .str_replace('%2F', '/', rawurlencode($install_dir.'upload/'.$value['element_value'])); } } else{ $mail_body .= $this->mail_line_break.$this->mail_line_break.$value['elementlabel_value'].': '.$value['element_value']; } } } $mail_body .= $this->mail_line_break.$this->mail_line_break.$this->dash_line; $mail_body .= $this->mail_line_break.'IP address: '.$_SERVER['REMOTE_ADDR']; $mail_body .= $this->mail_line_break.'Host: '.gethostbyaddr($_SERVER['REMOTE_ADDR']); if(preg_match('#html#', $this->mail_content_type_format_charset)) { $mail_body = nl2br($mail_body); } if($this->demo != 1) { // for the admin: if the user provides his email address, it will appear in the "from" field $param['reply_emailaddress'] = (isset($param['reply_emailaddress']) && $param['reply_emailaddress'])?$param['reply_emailaddress']:$this->cfg['email_address']; // for the admin: if the user provides his email address, it will appear in the "reply-to" field $replyto_name = $param['reply_emailaddress']?$param['reply_emailaddress']:''; $replyto_address = $param['reply_emailaddress']?$param['reply_emailaddress']:''; $mailheaders_options = array( 'from'=>array('name'=>$param['reply_emailaddress'], 'address'=>$param['reply_emailaddress']), 'replyto'=>array('name'=>$replyto_name, 'address'=>$replyto_address), 'cc'=>array('address'=>$this->cfg['email_address_cc']), 'bcc'=>array('address'=>$this->cfg['email_address_bcc']) ); $mailheaders = $this->getMailHeaders($mailheaders_options); //if(!isset($param['uploads']) || !$param['uploads']) if(!$count_files_to_attach) { $mailheaders .= $this->mail_content_type_format_charset."\r\n"; $mailmessage = $mail_body; } else { // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $mailheaders .= "MIME-Version: 1.0\n" ."Content-Type: multipart/mixed;\n" ." boundary=\"{$mime_boundary}\""; // multipart boundary $mailmessage = "This is a multi-part message in MIME format.\n\n" ."--{$mime_boundary}\n" .$this->mail_content_type_format_charset."\n" ."Content-Transfer-Encoding: 7bit\n\n" .$mail_body ."\n\n"; $mailmessage .= "--{$mime_boundary}\n"; // preparing attachments $count_attached_file = 0; foreach($this->merge_post as $value) { if( isset($value['element_type']) && $value['element_type'] == 'upload' && isset($value['filename']) && $value['filename'] && isset($value['deletefile']) && ($value['deletefile'] == 1 || $value['deletefile'] == 2) ) { $count_attached_file++; $file = fopen('../upload/'.$value['filename'],"rb"); $data = fread($file,filesize('../upload/'.$value['filename'])); fclose($file); $data = chunk_split(base64_encode($data)); $mailmessage .= 'Content-Type: {"application/octet-stream"};'."\n" . ' name="'.$value['filename'].'"'."\n" .'Content-Disposition: attachment;'."\n" . ' filename="'.$value['filename'].'"'."\n" .'Content-Transfer-Encoding: base64'."\n\n" . $data . "\n\n"; // "--" must be added for the last file, or an empty file will be also attached in the message if($count_attached_file == $count_files_to_attach) { $mailmessage .= "--{$mime_boundary}--\n"; } else{ $mailmessage .= "--{$mime_boundary}\n"; } // delete attached file? // this is different from deleting the file when the user deletes the file himself in the from: check form-validation.php for this (in form-validation.php because the file must be deleted even if sendMail() is not called - when there are errors for example) if(isset($value['deletefile']) && $value['deletefile'] == 2) { @unlink('../upload/'.$value['filename']); } } } // foreach } // if(!$count_files_to_attach) @mail($this->cfg['email_address'], $this->cfg['adminnotification_subject'], $mailmessage, $mailheaders); } } function sendMailReceipt($value) { if($this->demo != 1) { $mailheaders_options = array( 'from'=>array('name'=>$this->cfg['email_from'], 'address'=>$this->cfg['email_address']), 'replyto'=>array('name'=>$this->cfg['email_from'], 'address'=>$this->cfg['email_address']) ); $mailheaders = $this->getMailHeaders($mailheaders_options) .$this->mail_content_type_format_charset_usernotification."\r\n" ; $mail_body = ''; $mail_body .= $this->cfg['usernotification_message']; if($this->cfg['usernotification_insertformdata']) { $mail_body .= $this->mail_line_break_usernotification."--------------------------------------------------------"; foreach($this->merge_post as $form_data) { $mail_body .= $this->mail_line_break_usernotification.$this->mail_line_break_usernotification.$form_data['elementlabel_value'].': '.$form_data['element_value']; } } if(preg_match('#html#', $this->mail_content_type_format_charset_usernotification)) { $mail_body = nl2br($mail_body); } @mail($value['email_address'], $this->cfg['usernotification_subject'], $mail_body, $mailheaders); } } function mergePost($value) { $this->merge_post[$this->merge_post_index]['element_id'] = $value['element_id']; $this->merge_post[$this->merge_post_index]['element_value'] = $this->quote_smart(trim($value['element_value'])); $this->merge_post[$this->merge_post_index]['elementlabel_value'] = $this->quote_smart(trim($value['elementlabel_value'])); $this->merge_post[$this->merge_post_index]['elementlabel_id'] = $this->quote_smart(trim($value['elementlabel_id'])); if(isset($value['element_type']) && $value['element_type']) { // if element_type == upload, we add the download link in the mail body message $this->merge_post[$this->merge_post_index]['element_type'] = trim($value['element_type']); } if(isset($value['filename']) && $value['filename']) { $this->merge_post[$this->merge_post_index]['filename'] = $this->quote_smart(trim($value['filename'])); } if(isset($value['deletefile']) && $value['deletefile']) { $this->merge_post[$this->merge_post_index]['deletefile'] = trim($value['deletefile']); } $this->merge_post_index++; } function isEmail($email) { $atom = '[-a-z0-9\\_]'; // authorized caracters before @ $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // authorized caracters after @ $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i'; // test de l'adresse e-mail return preg_match($regex, trim($email)) ? 1 : 0; } function quote_smart($value) { if(get_magic_quotes_gpc()) { $value = stripslashes($value); } return $value; } function getMailHeaders($mailheaders_options) { $mailheaders_options['from']['name'] = isset($mailheaders_options['from']['name'])?$mailheaders_options['from']['name']:$mailheaders_options['from']['address']; $mailheaders_options['cc']['address'] = isset($mailheaders_options['cc']['address'])?$mailheaders_options['cc']['address']:''; $mailheaders_options['bcc']['address'] = isset($mailheaders_options['bcc']['address'])?$mailheaders_options['bcc']['address']:''; $from_name = $mailheaders_options['from']['name']?$mailheaders_options['from']['name']:$mailheaders_options['from']['address']; if($this->isEmail($from_name)) { // From: user@domain.com <user@domain.com> is invalid => user@domain.com $mail_header_from = 'From: '.$from_name."\r\n"; $mail_header_replyto = 'Reply-To: '.$from_name."\r\n"; } else { $mail_header_from = 'From: '.$from_name.'<'.$mailheaders_options['from']['address'].'>'."\r\n"; $mail_header_replyto = 'Reply-To: '.$from_name.'<'.$mailheaders_options['from']['address'].'>'."\r\n"; } $mail_header_cc = ''; if($mailheaders_options['cc']['address']) { $explode_email = explode(',', $mailheaders_options['cc']['address']); $cc = ''; foreach($explode_email as $email_value) { $cc .= $email_value.","; } $mail_header_cc .= 'Cc: '.substr($cc, 0, -1)."\r\n"; } $mail_header_bcc = ''; if($mailheaders_options['bcc']['address']) { $explode_email = explode(',', $mailheaders_options['bcc']['address']); $bcc = ''; foreach($explode_email as $email_value) { $bcc .= $email_value.","; } $mail_header_bcc .= 'Bcc: '.substr($bcc, 0, -1)."\r\n"; } $mailheaders = $mail_header_from .$mail_header_cc .$mail_header_bcc .$mail_header_replyto .'MIME-Version: 1.0'."\r\n" .'X-Mailer: PHP/'.phpversion()."\r\n" ; /* Examples of headers that should work would be: From: user@domain.com will work From: "user" <user@domain.com> Examples of headers that will NOT work: From: "user@domain.com" From: user @ domain.com From: user@domain.com <user@domain.com> */ // echo $mailheaders; return($mailheaders); } } /** * NO SPACES AFTER THIS LINE TO PREVENT * Warning: Cannot modify header information */ ?></code>
$mavaleur = isset($_POST['cfg-element-35-7'])?$_POST['cfg-element-35-7']:'';
<code>mavaleur = isset($_POST['cfg-element-35-7'])?$_POST['cfg-element-35-7']:''</code>
<code>/ enregistrement bd $nomprenom = isset($_POST['cfg-element-35-7'])?$_POST['cfg-element-35-7']:''; $DSN_string='mysql:host=********.eu.mysql;dbname=***********_eu'; $USER_string='************_eu'; $PWD_string='***********'; try { $PDOInstance = new PDO($DSN_string, $USER_string, $PWD_string); $PDOInstance->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); } catch (PDOException $e){print 'PDO_err : '.$e->getMessage();} // entree data $result=$PDOInstance->query("INSERT INTO matable (nomprenom) VALUES ('$nomprenom')");</code>
$nomprenom = isset($_POST['cfg-element-35-7'])?$_POST['cfg-element-35-7']:'No_Value';
$_POST['cfg-element-35-7']n'existe pas.... et dans ce cas.. on en revient encore une fois à ton script JQUERY .... C'est lui qui envoie récupère les données du formulaire pour les transmettre au fichier...
var TaVar = $("#cfg-element-35-7").val(); jQuery.post('cfg-contactform-35/inc/form-validation.php', //**************************************************************************************************************** { 'captcha_img':captcha_img, 'captcha_input':captcha_input, 'form_value_array':form_value_array, 'deleteuploadedfile':deleteuploadedfile_value, 'taVariable':TaVar },
$nomprenom = isset($_POST['taVariable'])?$_POST['taVariable']:'no-value';
<code> var TaVar = $("#cfg-element-35-7").val(); jQuery.post('cfg-contactform-35/inc/form-validation.php', { 'captcha_img':captcha_img, 'captcha_input':captcha_input, 'form_value_array':form_value_array, 'taVariable':TaVar, 'deleteuploadedfile':deleteuploadedfile_value },</code>
<code>$nomprenom = isset($_POST['taVariable'])?$_POST['taVariable']:'pas de valeur nomprenom'; $DSN_string='mysql:host=************.eu.mysql;dbname=***********_eu'; $USER_string='***********_eu'; $PWD_string='************'; try { $PDOInstance = new PDO($DSN_string, $USER_string, $PWD_string); $PDOInstance->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); } catch (PDOException $e){print 'PDO_err : '.$e->getMessage();} // entree data $result=$PDOInstance->query("INSERT INTO confid (nomprenom) VALUES ('$nomprenom')");
ça marche, il suffisait de mettre une ligne de code avant le "delette".
2 oct. 2014 à 20:25
..Est ce que dans ta page internet (celle qui contient le HTML que tu nous as montré précédement ).. tu as quelque part .. des balises ????
De plus.. le bout de code que tu nous montres... ne nous donnes pas vraiment d'indications
il ressemble à un SCRIPT (téléchargé tout fait) qui permet peut être de faire de l' UPLOAD de fichiers... Mais je n'ai pas l'impression que ça ait un rapport avec TA page ni même que tu puisses l'utiliser.
Attention.. toutes les questions que tu poses en ce moment sont du Javascript... et n'ont pas vraiment leur place dans la section PHP du forum.
Et pour en revenir à ton souci...
Tu veux que le traitement se fasse EN TEMPS REEL ?
ou après que l'utilisateur ait cliqué quelque part pour valider ?