Partage
  • Partager sur Facebook
  • Partager sur Twitter

Formulaire et tinymce

Formulaire qui ne submit pas avec TinyMCE

Sujet résolu
    24 juin 2017 à 9:02:33

    J'utilise tinymce pour ecrire des articles sur un blogs mais tous mes formulaires fonctionne sauf celui avec tinymce. Voila le code :

    <?php
    session_start();
    if(empty($_SESSION['key']) OR empty($_SESSION['pseudo'])){
    	header('Location: https://site.com/members/login/');
    }
    if(isset($_POST['title']) AND isset($_POST['text']) AND isset($_POST['extrait'])){
    	$titre = htmlspecialchars($_POST['title']);
    	$texte = $_POST['text'];
    	$chaine = htmlspecialchars($_POST['extrait']);
    	$time = time();
    	$hash = uniqid(null, true);
    	$host_name = "host.com";
    	$database = "db";
    	$user_name = "user";
    	$password = "pass";
    	
    	$max = 150;  
    
    	if (strlen($chaine) >= $max) {
    	  $chaine = substr($chaine, 0, $max);  
    	  $espace = strrpos($chaine, " ");  
    	  $chaine = substr($chaine, 0, $espace)."...";
    	}
    
    	$bdd = null;
    	try {
    	  $bdd = new PDO("mysql:host=$host_name; dbname=$database;", $user_name, $password);
    	} catch (PDOException $e) {
    	  echo "Erreur!: " . $e->getMessage() . "<br/>";
    	  die();
    	}
    	$req = $bdd->prepare('INSERT INTO code(title, text, extrait, timestamp, author, hash) VALUES(:title, :text, :chaine, :timestamp, :author, :hash)');
    
    	$req->execute(array(
    		'title' => $titre,
    		'text' => $texte,
    		'chaine' => $chaine,
    		'timestamp' => $time,
    		'author' => $_SESSION['pseudo'],
    		'hash' => $hash
    		));
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
           "http://www.w3.org/TR/html4/loose.dtd">
    <html lang="fr">
    	<head>
      	  <style type="text/css">
    		   /*
    			 * Visual Studio 2015 dark style
    			 * Author: Nicolas LLOBERA <nllobera@gmail.com>
    			 */
    			.hljs {
    			  display: block;
    			  overflow-x: auto;
    			  padding: 0.5em;
    			  background: #1E1E1E;
    			  color: #DCDCDC;
    				border-radius: 3px;
    			}
    
    			.hljs-keyword,
    			.hljs-literal,
    			.hljs-symbol,
    			.hljs-name {
    			  color: #569CD6;
    			}
    			.hljs-link {
    			  color: #569CD6;
    			  text-decoration: underline;
    			}
    
    			.hljs-built_in,
    			.hljs-type {
    			  color: #4EC9B0;
    			}
    
    			.hljs-number,
    			.hljs-class {
    			  color: #B8D7A3;
    			}
    
    			.hljs-string,
    			.hljs-meta-string {
    			  color: #D69D85;
    			}
    
    			.hljs-regexp,
    			.hljs-template-tag {
    			  color: #9A5334;
    			}
    
    			.hljs-subst,
    			.hljs-function,
    			.hljs-title,
    			.hljs-params,
    			.hljs-formula {
    			  color: #DCDCDC;
    			}
    
    			.hljs-comment,
    			.hljs-quote {
    			  color: #57A64A;
    			  font-style: italic;
    			}
    
    			.hljs-doctag {
    			  color: #608B4E;
    			}
    
    			.hljs-meta,
    			.hljs-meta-keyword,
    			.hljs-tag {
    			  color: #9B9B9B;
    			}
    
    			.hljs-variable,
    			.hljs-template-variable {
    			  color: #BD63C5;
    			}
    
    			.hljs-attr,
    			.hljs-attribute,
    			.hljs-builtin-name {
    			  color: #9CDCFE;
    			}
    
    			.hljs-section {
    			  color: gold;
    			}
    
    			.hljs-emphasis {
    			  font-style: italic;
    			}
    
    			.hljs-strong {
    			  font-weight: bold;
    			}
    
    			/*.hljs-code {
    			  font-family:'Monospace';
    			}*/
    
    			.hljs-bullet,
    			.hljs-selector-tag,
    			.hljs-selector-id,
    			.hljs-selector-class,
    			.hljs-selector-attr,
    			.hljs-selector-pseudo {
    			  color: #D7BA7D;
    			}
    
    			.hljs-addition {
    			  background-color: #144212;
    			  display: inline-block;
    			  width: 100%;
    			}
    
    			.hljs-deletion {
    			  background-color: #600;
    			  display: inline-block;
    			  width: 100%;
    			}
    
    		</style>
    	<script type="text/javascript" src="tinymce/tinymce.min.js"></script> 
    		  <script type="text/javascript">
    			  tinymce.init({
    				  selector: 'textarea',
    				  height: 500,
    				  theme: 'modern',
    				  plugins: [
    					'advlist autolink lists link image charmap print preview hr anchor pagebreak',
    					'searchreplace wordcount visualblocks visualchars code fullscreen',
    					'insertdatetime media nonbreaking save table contextmenu directionality',
    					'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc help'
    				  ],
    				  codesample_languages: [
    					{text: 'Apache', value: 'apache'},
    					{text: 'Bash', value: 'bash'},
    					{text: 'CoffeeScript', value: 'coffeescript'},
    					{text: 'C++', value: 'cpp'},
    					{text: 'C#', value: 'csharp'},
    					{text: 'CSS', value: 'css'},
    					{text: 'Diff', value: 'diff'},
    					{text: 'HTTP', value: 'http'},
    					{text: 'Ini', value: 'ini'},
    					{text: 'Java', value: 'java'},
    					{text: 'JavaScript', value: 'javascript'},
    					{text: 'JSON', value: 'json'},
    					{text: 'Makefile', value: 'makefile'},
    					{text: 'Markdown', value: 'markdown'},
    					{text: 'Nginx', value: 'nginx'},
    					{text: 'Objective-C', value: 'objectivec'},
    					{text: 'Perl', value: 'perl'},
    					{text: 'PHP', value: 'php'},
    					{text: 'Python', value: 'python'},
    					{text: 'Ruby', value: 'ruby'},
    					{text: 'Shell Session', value: 'shell session'},
    					{text: 'SQL', value: 'sql'},
    					{text: 'HTML,XML', value: 'markup'}
    					], 
    				  toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
    				  toolbar2: 'print preview media | forecolor backcolor emoticons | codesample help',
    				  image_advtab: true,
    				  content_css: [
    					'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
    					'//www.tinymce.com/css/codepen.min.css'
    				  ]
    				 });
    			</script>
    	  <meta charset="utf-8" />
    	  <title>Ajouter un code - ZeProf2C</title>
    	</head>
    	<body> <?php $hr=true; require('/homepages/15/d686824551/htdocs/header.php'); ?>
    		<p style="text-align:center;"><b>Ajouter des codes open-sources</b></p>
    		<article>
    			<p>Ici vous pouvez publier un code ou un article sur la page <a href="/code/" class="link"> Code </a>. Ces codes sont open-sources: ils peuvent être réutiliser sans citer les sources ni l'auteur mais ne peuvent pas être vendus. Lorsque vous publier un article, je le vérifierai avant de le publier.</p>
    				<form action="#" method="post">
    				  <fieldset>
    					<legend>Nouveau code : </legend>
    						Titre:
    						<br>
    						<input type="text" name="title" id="title" placeholder="Titre" autofocus required>            
    						<br>
    						<br>
    						Article:
    						<br>
    						<textarea id="text" name="text" rows="25" ></textarea>
    						<br>
    						<br>
    						Extrait:
    						<br>
    						<input type="text" name="extrait" id="extrait" placeholder="extrait" required>            
    						<br>
    						<br>
    						<input type="submit" value="Envoyer">
    				  </fieldset>
    				</form>
    		</article>
    	</body>
    </html>
    

    Le probleme est que j'ai beau cliquer sur envoyer, rien ne se passe !

    Si qqun a une idee MERCI !

    PS : J'ai delete et recreer la page et sa fonctionne

    -
    Edité par Rennor974 24 juin 2017 à 9:21:44

    • Partager sur Facebook
    • Partager sur Twitter

    Formulaire et tinymce

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown