Jump to content

textarea not submitting


Orionsbelter

Recommended Posts


<?php
session_start();
$username=$_SESSION['username'];
include_once"../includes/db_connect.php";
$start=$_GET['start'];
$id=$_GET['id'];

if($_POST['startButton'] && $_POST['name']){
$name=$_POST['name'];
mysql_query("INSERT INTO  `products` (  `id` ,  `name` ) VALUES ('',  '$name');");
$insert_id=mysql_insert_id();
header("Location: addProduct.php?id=$insert_id");
}
$products=mysql_fetch_object(mysql_query("SELECT * FROM `products` WHERE `id`='$id'"));
$categories=mysql_fetch_object(mysql_query("SELECT `name` FROM `categories` WHERE `departmentID`='$products->department'"));
$subCategories=mysql_fetch_object(mysql_query("SELECT `name` FROM `subCategories` WHERE `catergoryID`='$products->category'"));
if($products->department=="1"){$depart="Collections";}
if($products->department=="2"){$depart="Accessories";}
if($products->department=="3"){$depart="Childrens Wear";}

if($products->subcategory=="0"){$breadCat="$depart > $categories->name";}else{$breadCat="$depart > $categories->name >  $subCategories->name";}

if($_POST['update']){
$editor=$_POST['editor'];
$price=$_POST['price'];
mysql_query("UPDATE `products` SET `price`='$price' WHERE `id`='$id'");
mysql_query("UPDATE `products` SET `description`='$editor' WHERE `id`='$id'");
echo"$editor <<";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DT$breadCatD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../includes/main.css" rel="stylesheet" type="text/css" media="all"/> 
<!-- Combo-handled YUI CSS files: -->
<link rel="stylesheet" type="text/css" href="../includes/skin.css">
<!-- Combo-handled YUI JS files: -->
<script type="text/javascript" src="../includes/editor.js"></script>
<title></title>
<style type="text/css">
#contentBox {
background:#EEE;
border:5px #333 solid;
width:917px;
padding:5px;
color:#000;
font-weight: bold;
}
#space {
width:100%;
height:15px;
}
.productName {
font-family: Tahoma, Geneva, sans-serif;
font-size: 18px;
}
.price {
font-family: Tahoma, Geneva, sans-serif;
font-size: 16px;
}
.titleBox{
height:22px;
width:600px;
background-color:#CCC;
border:#333 1px solid;
font-family:Tahoma, Geneva, sans-serif;
font-size:14px;
}
#titleHead{
width:99%;
height:18px;
background-color:#333;
font-family:Verdana, Geneva, sans-serif;
font-size:14px;
font-weight:bold;
color:#FFF;
padding:3px;
}
#main{
width:99%;
background-color:#999;
font-family:Tahoma, Geneva, sans-serif;
font-size:12px;
color:#000;
font-weight:normal;
padding:3px;
}
.priceInput{
height:18px;
width:70px;
font-family:Tahoma, Geneva, sans-serif;
font-size:12px;
color:#000;
}
.yui-skin-sam .yui-toolbar-container .yui-toolbar-inserticon span.yui-toolbar-icon {
    background-image: url( ../images/icons/smile/suits_default.gif );
    background-position: 4px 1px;
height:18px;
width:23px;
}
.yui-skin-sam .yui-toolbar-container .yui-button-insertdate-selected span.yui-toolbar-icon {
    background-image: url( ../images/icons/smile/suits_active.gif );
    background-position: 4px 1px;
height:18px;
width:23px;
}
#iconMenu {
border:#999 1px solid;
background:#f5f5f5;
}
.imgIc{
border:0px;
padding:2px;
}
.imgIc:hover{
border:#666 1px solid;
padding:2px;
}
</style>
<script type="text/javascript">
function validateForm()
{
var department=document.forms["form3"]["jumpMenu3"].value;
var department=document.forms["form3"]["jumpMenu3"].value;
var department=document.forms["form3"]["jumpMenu3"].value;


}
</script>
</script>

</head>

<body class="yui-skin-sam">
<?php include"../header.php";?>
<div id="mainBody" align="center">
<div id="mainBodyContainer" align="left">
<div id="space"></div>
<div id="contentBox">
  <form id="form" name="form" method="post" action=""><span class="productName" style="padding-bottom:6px;">Product Name</span><br />
      <input name="name" type="text" class="titleBox" id="name" value="<?php echo"$products->name";?>" />
    <br />
     <br />
    <label>
      <?php if($start=="0"){ ?>
      <input name="startButton" type="submit" id="startButton" value="Update" />
      <br />
      <br />
    </label>
     <div id="titleHead">Unfinished Product</div>
<div id="main">
<?php 
$query=mysql_query("SELECT `name`, `id` FROM `products` WHERE `price`='0.00' OR `category`='0'");
while($fetch=mysql_fetch_object($query)){
 echo"<a href=\"addProduct.php?id=$fetch->id\">$fetch->name</a><br>";
}
?>
<br />
   </div>
<br />
<?php } if($start!=="0"){ ?>
<div id="titleHead">Select Master Category</div>
  <div id="main"><a href="addMaster.php?id=<?php echo"$id";?>" class="links">Add Master Category</a><br />
    <br />
   <span class="text1"><?php echo"$breadCat"; ?></span>
  </div>
  <br />
  <div id="titleHead">Product Images</div>
  <div id="main">
    <iframe src="upload.php?id=<?php echo"$id";?>" height="200" width="98%" style="border:none;"></iframe>
  </div>
  <br />
  <div id="titleHead">Product Description </div>
  <div id="main"><label><textarea id="editor" name="editor" rows="20" cols="75"></textarea> </label></div>
   <br />
  <div id="titleHead">Product Variants</div>
  <div id="main"><a href="addVariant.php?id=<?php echo"$id";?>" class="links">Add A Variant</a><br />
    <br />
<?php 
$queryVariants=mysql_query("SELECT `name`, `id` FROM `variants` WHERE `productID`='$id'");
while($fetchVariants=mysql_fetch_object($queryVariants)){
echo'
 <label>
   '. $fetchVariants->name.':
      <select name="'.$fetchVariants->name.'" id="'.$fetchVariants->name.'">';
$queryVO=mysql_query("SELECT `name` FROM `variantsOptions` WHERE `productID`='$id' AND `variantID`='$fetchVariants->id'");
while($fetchVO=mysql_fetch_object($queryVO)){
echo"<option value='".$fetchVO->name."'>".$fetchVO->name."</option>";
}
     echo'</select>
    </label>
    <a href="addVariant.php?id='.$id.'&edit=1&vid='.$fetchVariants->id.'">[edit]</a><br />';
}
?>
  </div>
   <br />
  <div id="titleHead">Advanced Options</div>
  <div id="main"><a href="catManage.php?id=<?php echo"$id"?>" class="links">Category Management
    </a><br />
  </div>
  <p><span class="price">Price:</span> £
    <label>
  <input name="price" type="text" class="priceInput" id="price" value="0.00" />
</label>
  </p>
    <label>
      <input name="update" type="submit" id="update" value="Update" />
    </label>
    <?php } ?>
  </form>
</div>
<div id="space"></div>
</div>
</div>
<script>
(function() {
    var myConfig = {
        height: '180px',
        width: '100%',
        animate: true,
        dompath: true,
        focusAtStart: true
    };
    myEditor = new YAHOO.widget.Editor('editor', myConfig);

    YAHOO.util.Event.onAvailable('iconMenu', function() {
        YAHOO.util.Event.on('iconMenu', 'click', function(ev) {
            var tar = YAHOO.util.Event.getTarget(ev);
            if (tar.tagName.toLowerCase() == 'img') {
                var img = tar.getAttribute('src', 2);
                var _button = this.toolbar.getButtonByValue('inserticon');
                _button._menu.hide();
                this.toolbar.fireEvent('inserticonClick', { type: 'inserticonClick', icon: img });
            }
            YAHOO.util.Event.stopEvent(ev);
        }, myEditor, true);
    });

//Inside an event handler after the Editor is rendered
YAHOO.util.Event.on('button', 'click', function() {
    //Put the HTML back into the text area
    myEditor.saveHTML();

    //The var html will now have the contents of the textarea
    var html = myEditor.get('element').value;
});

    myEditor.on('toolbarLoaded', function() { 
       
        var imgConfig = {
            type: 'push', label: 'Insert Icon', value: 'inserticon',
            menu: function() {
                var menu = new YAHOO.widget.Overlay('inserticon', {
                    width: '165px',
                    height: '210px',
                    visible: false
                });
                var str = '';
                for (var a = 0; a < 1; a++) {
                    for (var i = 1; i < 54; i++) {
                        str += '<a href="#"><img src="../images/icons/smile/suit' + i + '.gif" class="imgIc"></a>';
                    }
                }
                menu.setBody('<div id="iconMenu">' + str + '</div>');
                menu.beforeShowEvent.subscribe(function() {
                    menu.cfg.setProperty('context', [
                        myEditor.toolbar.getButtonByValue('inserticon').get('element'),
                        'tl', 'bl'
                    ]);
                });            
                menu.render(document.body);
                menu.element.style.visibility = 'hidden';
                return menu;
            }()
        };
        myEditor.toolbar.addButtonToGroup(imgConfig, 'insertitem');

        myEditor.toolbar.on('inserticonClick', function(ev) {
            var icon = '';
            this._focusWindow();
            if (ev.icon) {
                icon = ev.icon;
            }
            this.execCommand('inserthtml', '<img src="' + icon + '" border="0">');
        }, myEditor, true);

    });
myEditor._defaultToolbar.titlebar = false;
    myEditor.render();
})();
</script>
<?php include"../footer.php";?>
</body>
</html>

 

the textarea $editor isn't submitting into the database at all and when i echo the return when i click the submit button the variable is completely empty even though i see no error or mistake can anyone see why this isn;t working.

Link to comment
Share on other sites

A couple of questions.

 

First, is the row being updated at all in the database, and just the description is becoming empty? or is the row not being updated at all? Do you have any mysql errors? Are you sure that if statement is executing as true? For your echo, is not echoing nothing at all (IE not even being executed) or is editor variable simply empty?

 

A couple of things you need to try to give a little more information before anyone can help you.

 

First, turn error reporting on (Nothing in that code seems to indicate what the status is for error reporting). You can achieve this by sticking the following code at the top of your page

 

ini_set('display_errors',1);
error_reporting(E_ALL);

 

Secondly, try viewing the structure of the $_POST array, so you can determine whether it looks like you expect it to look like. This can be achieved with the following code

 

print_r($_POST);

 

Beyond that, you haven't really given enough information to help you. Your code SEEMS ok, but there may be some underlying problem that isn't readily apparent.

 

As a side note, when posting code, please only post the relevant code. It makes it much easier for us to help you when we don't have to trudge through a bunch of irrelevant CSS and Javascript.

 

Hope this helps

 

 

Link to comment
Share on other sites

HI thank you for your reply, there is no mysql_error or php errors been displayed.

 

on the print_r it gives < Dress [editor] => [Colour] => Black => size 6 [price] => 0.00 [update] => Update ) it seems that the editor still is been posted as blank even though i enter some text into the field.

 

:(

 

it seems to be picking up the textarea but not value :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.