Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Ryan R


Recommended Posts

Hi All,


I made a add_page.php according to the book "effortless e-commerce".


If you look at the content box on my web page (here's the link: http://ryan.divinehosting.ca/add_page.php), you will notice that your cursor starts way below the tool bar. So if I want to type something, I need to start from in the middle of this blank box. Also, if you go down hitting "enter" as you keep typing, the background of this website is showing up in this blank box..


It's weird...


Thanks in advance for your help and look forward to hearing from you soon.

Share this post

Link to post
Share on other sites

You can login as an administer. I will change this info right after having your advice.


Admin email: forkhyun@gmail.com

Amdin password : Liverfolk81


add_page.php codes I put on are below:





// This page is used by an administrator to create a specific page of HTML content.

// This script is created in Chapter 5.


// Require the configuration before any PHP code as the configuration controls error reporting:

require ('./includes/config.inc.php');


// If the user isn't logged in as an administrator, redirect them:



// Include the header file:

$page_title = 'Add a Site Content Page';

include ('./includes/header.html');


// Require the database connection:



// For storing errors:

$add_page_errors = array();


// Check for a form submission:



// Check for a title:

if (!empty($_POST['title'])) {

$t = mysqli_real_escape_string($dbc, strip_tags($_POST['title']));

} else {

$add_page_errors['title'] = 'Please enter the title!';



// Check for a category:

if (filter_var($_POST['category'], FILTER_VALIDATE_INT, array('min_range' => 1))) {

$cat = $_POST['category'];

} else { // No category selected.

$add_page_errors['category'] = 'Please select a category!';



// Check for a description:

if (!empty($_POST['description'])) {

$d = mysqli_real_escape_string($dbc, strip_tags($_POST['description']));

} else {

$add_page_errors['description'] = 'Please enter the description!';



// Check for the content:

if (!empty($_POST['content'])) {

$allowed = '<div><p><span><br><a><img><h1><h2><h3><h4><ul><ol><li><blockquote>';

$c = mysqli_real_escape_string($dbc, strip_tags($_POST['content'], $allowed));

} else {

$add_page_errors['content'] = 'Please enter the content!';



if (empty($add_page_errors)) { // If everything's OK.


// Add the page to the database:

$q = "INSERT INTO pages (category_id, title, description, content) VALUES ($cat, '$t', '$d', '$c')";

$r = mysqli_query ($dbc, $q);


if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.


// Print a message:

echo '<h4>The page has been added!</h4>';


// Clear $_POST:

$_POST = array();


// Send an email to the administrator to let them know new content was added?


} else { // If it did not run OK.

trigger_error('The page could not be added due to a system error. We apologize for any inconvenience.');



} // End of $add_page_errors IF.


} // End of the main form submission conditional.


// Need the form functions script, which defines create_form_input():

require ('includes/form_functions.inc.php');


<h3>Add a Site Content Page</h3>

<form action="add_page.php" method="post" accept-charset="utf-8">


<fieldset><legend>Fill out the form to add a page of content:</legend>


<p><label for="title"><strong>Title</strong></label><br /><?php create_form_input('title', 'text', $add_page_errors); ?></p>


<p><label for="category"><strong>Category</strong></label><br />

<select name="category"<?php if (array_key_exists('category', $add_page_errors)) echo ' class="error"'; ?>>

<option>Select One</option>

<?php // Retrieve all the categories and add to the pull-down menu:

$q = "SELECT id, category FROM categories ORDER BY category ASC";

$r = mysqli_query ($dbc, $q);

while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) {

echo "<option value=\"$row[0]\"";

// Check for stickyness:

if (isset($_POST['category']) && ($_POST['category'] == $row[0]) ) echo ' selected="selected"';

echo ">$row[1]</option>\n";



</select><?php if (array_key_exists('category', $add_page_errors)) echo ' <span class="error">' . $add_page_errors['category'] . '</span>'; ?></p>


<p><label for="description"><strong>Description</strong></label><br /><?php create_form_input('description', 'textarea', $add_page_errors); ?></p>


<p><label for="content"><strong>Content</strong></label><br /><?php create_form_input('content', 'textarea', $add_page_errors); ?></p>


<p><input type="submit" name="submit_button" value="Add This Page" id="submit_button" class="formbutton" /></p>






<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>

<script type="text/javascript">


// General options

mode : "exact",

elements : "content",

theme : "advanced",

width : 800,

height : 400,

plugins : "advlink,advlist,autoresize,autosave,contextmenu,fullscreen,iespell,inlinepopups,media,paste,preview,safari,searchreplace,visualchars,wordcount,xhtmlxtras",


// Theme options

theme_advanced_buttons1 : "cut,copy,paste,pastetext,pasteword,|,undo,redo,removeformat,|,search,replace,|,cleanup,help,code,preview,visualaid,fullscreen",

theme_advanced_buttons2 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,bullist,numlist,|,outdent,indent,blockquote,|,sub,sup,cite,abbr",

theme_advanced_buttons3 : "hr,|,link,unlink,anchor,image,|,charmap,emotions,iespell,media",

theme_advanced_toolbar_location : "top",

theme_advanced_toolbar_align : "left",

theme_advanced_statusbar_location : "bottom",

theme_advanced_resizing : true,


// Example content CSS (should be your site CSS)

content_css : "/css/styles.css",




<!-- /TinyMCE -->




// Include the footer file to complete the template:

include ('./includes/footer.html');



Share this post

Link to post
Share on other sites

I think the problem is due to the width of the textarea. If I shrink the width, the cursor moves to where it should be.

Share this post

Link to post
Share on other sites

Hi Larry,



Thanks for your reply.

I reduced the width to 600. But it still has the same problem as before. I wonder the js file I attached has some problem. I put "tiny_mce" folder in my web root of the server. In tiny_mce, there are 'langs'folder, 'plugins' folder, 'themes' folder, 'utils' folder, licence, tiny_mce.js, tiny_mce_popup.js,and tiny_mce_src.js.


So it will look like it below.


www - tiny_mce - 'langs', 'plugins', 'themes', 'utils', licence, tiny_mce.js, tiny_mce_popup.js, tiny_mce_src.js.



Thanks again and look forward to hearing from you soon.



Share this post

Link to post
Share on other sites

If you use a browser which allows you to dynamically resize the textarea (I used Safari), you'll see that it's an issue with the width of the textarea. Has nothing to do with the JavaScript.

Share this post

Link to post
Share on other sites

Hi Larry,


Thank you for your advice. I am using firefox. It doesn't show me anything about the width. It's kinda frustrating that I can't fix this issue..


Thanks for your help.



Share this post

Link to post
Share on other sites

Hi Larry,


I just upgrade it to Firefox 5. How can I resize them? Can you show me how to do that? Sorry for asking again.


Thanks for your help. I appreciate your help.



Share this post

Link to post
Share on other sites

In the bottom right hand corner of a text area you will see two small lines at a 45 degree angle.


Put your mouse over them, hold in the the left button (on a PC) and drag.


This will resize the area.


My cursor in Tiny_MCE does as yours does too.


Hope that helps

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...