PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 31st, 2013, 08:06 AM
Aurum84 Aurum84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 74 Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 23 h 5 m 49 sec
Reputation Power: 17
PHP5 - Issue with tinymce in php

I am currently making my own simple CMS, just for the fun of it, and to spend some spare time. I am not sure that the problem that I have should be classified as php or html.

I looked at the tutorial at http://www.w3programmers.com/build-a-cms-with-php-oop-and-mysql-part-2/ to get started, and made some custom changes.

The problem arises in the admin part. There I have a list of articles. The administrator can edit existing articles, add new articles or remove articles. Both edit and adding functionality work as expected.
However, I added a tinyMCE editor. The editing panel looks nicer now, and I can still edit existing articles, but I can not add new articles. The submit button does not seem to respond at all, even though it is the exact same page as used for the editpage (same page, different action). Can somebody enlighten me here?

The code for the article editor view (views/editArticle.php) is:

PHP Code:
<?php include "templates/admin/include/header.php";
?>
<script src = "js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script>
tinyMCE.init({
        // General options
        mode : "textareas",
        theme : "advanced",
        plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell  ,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,full  screen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        
});
</script>
<?php

echo '

<h2>Widget News Admin</h2>
</header>
<p>You are logged in as <b> '
.htmlspecialchars$_SESSION['username']) .'</b><a href="index.php?action=logout">Log out</a></p>


<h1>'
;
$results['pageTitle'];

echo 
'</h1>

<form action="index.php?action='
htmlspecialchars($results['formAction']).'" method="post">

<input type="hidden" name="articleId" value="'
.(int) $results['article']->id .'"/>';

if ( isset( 
$results['errorMessage'] ) ) { 

echo 
'<div>'$results['errorMessage'].'</div>';

 } 
echo 
'<ul><li><label for="title">Article Title</label>';
echo 
'<input type="text" name="title" id="title" placeholder="Name of the article" required autofocus maxlength="255" value="'.htmlspecialchars$results['article']->title ).'" />';
echo 
'</li><li><label for="summary">Article Summary</label>';
echo 
'<textarea name="summary" id="summary" placeholder="Brief description of the article" required maxlength="1000" >'.htmlspecialchars$results['article']->summary).'</textarea>';
echo 
'</li><li><label for="content">Article Content</label>';
echo 
'<textarea name="content" id="content" placeholder="The HTML content of the article" required maxlength="100000" >'.htmlspecialchars$results['article']->content ).'</textarea>';
echo 
'</li></ul><div>';
echo 
'<input type="submit" name="saveChanges" value="Save Changes" />';
echo 
'<input type="submit" formnovalidate name="cancel" value="Cancel" />';
echo 
'</div></form>';




if ( 
$results['article']->id ) { 

echo 
'<p><a href="index.php?action=deleteArticle&articleId='.(int)$results['article']->id.'">';
echo 
'Delete This Article</a></p>';



include 
"templates/admin/include/footer.php";


The code for adding a new article (newArticle.php) is:

PHP Code:
<?php

$results 
= array();

$results['pageTitle'] = "New Article";

$results['formAction'] = "newArticle";

if ( isset( 
$_POST['saveChanges'] ) ) {

// User has posted the article edit form: save the new article
$article = new Article();

$article->storeFormValues$_POST );

$article->insert();

header"Location: index.php?status=changesSaved" );

} elseif ( isset( 
$_POST['cancel'] ) ) {

// User has cancelled their edits: return to the article list

header"Location: index.php" );

} else {

// User has not posted the article edit form yet: display the form

$results['article'] = new Article();

require( 
"templates/admin/views/editArticle.php" );

}

?>


The code for index.php is:

PHP Code:
<?php

session_start
();
require( 
"../PDOConnect.php" );
require(
"../defines.php");
require(
"../core.php");

$action = isset( $_GET['action'] ) ? $_GET['action'] : "";

if ( 
$action != "login" && $action != "logout" && !isset($_SESSION['username']) ) {

    require(
'login.php');

    exit;

}

switch ( 
$action ) {

    

    case 
'newArticle':

        require(
'newArticle.php');

        break;

    ......

    default:

        require(
'listArticles.php');

}



?>

Reply With Quote
  #2  
Old January 31st, 2013, 05:05 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,931 E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 7 h 43 m 47 sec
Reputation Power: 7053
If the submit button doesn't submit an HTTP request back to the server then you have a client side issue, but I don't see it in your code. See if you're getting any JavaScript errors.

The other possibility is that your action URL is the same as the URL you're currently viewing, and it is actually submitting but you didn't realize that.

Are you sure $_POST['saveChanges'] is actually not empty?
__________________
PHP FAQ
How to program a basic, secure login system using PHP

Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #3  
Old February 2nd, 2013, 11:59 AM
Aurum84 Aurum84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 74 Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level)Aurum84 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 23 h 5 m 49 sec
Reputation Power: 17
I found the source of the problem:

the tinyMCE converted the textareas to texteditors, however these formelements still had the 'required' attribute. So there was a conflict while validating and the errors were not posted. By removing this attribute the form could be posted as expected.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP5 - Issue with tinymce in php

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap