Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2009-02-13 21:47:41

fembot
New member
Registered: 2006-07-21
Posts: 5

php post textarea problem

Hi I am new to php and xinha and am trying to use simple news as a cms for my site. i would like to use xinha as an editor. Though xinha shows up on the page it will not post and receives an error that all info was not received. Any ideas?

the php code is:

Offline

#2 2009-02-13 21:49:14

fembot
New member
Registered: 2006-07-21
Posts: 5

Re: php post textarea problem

<?
//File to keep news in.  If you are using the secure setup described in the
//readme with post.php in an .htaccessed admin dir you must update the location
//of news.txt file in the next variable.
$newsfile = "../news.htm";
//Open news.txt in read mode. 
$file = fopen($newsfile, "r");
//Table Vars The below variables are inserted verbatim into the news.txt file.
//This gives you a lot of control over how the news will look.  The
//disadvantage is that if you ever decide you don't like how these look you
//can't change one thing like with CSS to adapt it to your liking.  You will
//have to do a mass "find and replace" on the news.txt file.  In other words:
//these are essentially the HTML tags that will go around your entries. 
//b=begin  e=end
$btable = "<table class='sn'> <tbody>";
$btitle = "<tr><td class='sn-title'>";
$etitle = "</td></tr>";
$bdate = "<tr><td class='sn-date'> Posted on:";
$edate = "</td></tr>";
$bpost = "<tr><td class='sn-post'>";
$epost = "</td></tr>";
$etable = "</tbody></table><div><br /></div>";
//Define PHP Date format.  Used for the default date form value. 
$defdate=date("m/d/Y");
//Other notes
//The date is automatically set to todays date by using PHP to echo the
//variable of defdate.  The form action uses this file itself to process the
//data. 
// The If/Else statements decide what is displayed based on whether a HTTP GET
// or POST was issued by the browser.  GET: If the submit button has not been
// pushed -- display form.  PUT: Submit button has been pushed -- write data to
// text file and display confirmation message. 
//IF browser does not send a POST request (ie: if submit has not been pressed)
//then display the form....
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
//If able to open file do...
if ($file) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/javascript">
    _editor_url  = "../xinha/"  // (preferably absolute) URL (including trailing slash) where Xinha is installed
    _editor_lang = "en";      // And the language we need to use in the editor.
    _editor_skin = "silva";   // If you want use a skin, add the name (of the folder) here
  </script>
<script type="text/javascript" src="../xinha/XinhaCore.js"></script>
<script type="text/javascript" src="../xinha/my_config.js"></script>
<style type="text/css">
h2 {
    text-align: center
}
</style>
<title>News: Post</title>
</head>
<body>
<h2>News: Post An Entry</h2>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
  <div style="text-align: center"> Title:
    <input type="text" name="title" />
    <br />
    Date:
    <input type="text" name="date" value="<? echo $defdate; ?>" />
    <br />
    Entry:<br />
    <textarea id="newbiearea1" name="newbiearea1" rows="30" cols="80" style="border: 1px solid #666666;" name="post">
    </textarea>
    <br />
    <input type="submit" value="Add News" />
  </div>
</form>
</body>
</html>
<?
}
else
//If can not open file complain...
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
     \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html><head><title>Simple News: Error </title></head><body><p>Could not open file. <br /> Permissions??</p></body></html>";
}
//ELSE IF browser sends a POST request. Make sure that data was actually
//entered into the form and then write that data to the file....
elseif ((isset($_REQUEST["title"])) && (isset($_REQUEST["date"])) &&
(isset($_REQUEST["post"])) && ($_REQUEST["title"]!="") &&
($_REQUEST["date"]!="") && ($_REQUEST["post"]!="")) {
//The next few lines are a hacked up way to "add" text to the top of a file.
//// The file is already opened in read mode.  Read in all the current data
//from news.txt.  Save this as variable current_data.
$current_data = @fread($file, filesize($newsfile));
//Now that we have saved the old data to a variable lets close the file.
fclose($file);
//Now we reopen the file in write mode.  This FIRST blanks the file.  Then will
//will write the new data followed by the old data to the file. 
$file = fopen($newsfile, "w");
//Write all of the table variables and the text entered into the form, plus the
//text that was already in news.txt to news.txt. The \n is a new line and it
//simply make news.txt more beautiful.  If it works display success message, if
//not display failure message.

//// Fix quotes (') in entries and change any weird
//characters (&,<,>,etc) to their html equivalents.  Do the same for title and
//date. Even though it should not be needed for date. 
$_REQUEST["post"] = stripslashes(($_REQUEST["post"]));
$_REQUEST["date"] = stripslashes(($_REQUEST["date"]));
$_REQUEST["title"] = stripslashes(($_REQUEST["title"]));
if(fwrite($file,$btable . " " . $btitle . " " . $_REQUEST["title"] . " " .  $etitle . " " . $bdate . " " . $_REQUEST["date"] . " " . $edate . " " . $bpost . " " . $_REQUEST["post"] . " " . $epost . " " . $etable . "\n " . $current_data))
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html><head><title>News: Entry Added</title></head><body><p>Entry added successfully.<br /> <a href=\"\">Add</a> another.</p></body></html>";
else
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
     \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html><head><title>News: Entry NOT Added!</title></head><body><p>Could not add entry.<br /> Permissions??</p></body></html>";
//Close the file. 
fclose($file);
}
//If the browser sent a POST request but the user failed to put data in the
//form...spit out this error.   
else
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
     \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html><head><title>News: Entry NOT Added!</title></head><body><p>Could not add entry. <br /> All the fields in the form are *required*. <br /> Please go back and try again.</p></body></html>";
?>

Offline

#3 2009-02-25 06:35:49

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: php post textarea problem

<textarea id="newbiearea1" name="newbiearea1" rows="30" cols="80" style="border: 1px solid #666666;" name="post">

Spot your mistake.


James Sleeman

Offline

#4 2010-03-15 12:34:05

rapper
New member
Registered: 2010-03-15
Posts: 2

Re: php post textarea problem

Hi,

php $_REQUEST variable for xinha text area is not returned (normal submit button)

url for test page is http://i-net-sales.com/rap_admin/xinhatest.php

source code follows:
_______________________________
<?
$action = 'editmail';

        if($_POST['submit']){
            echo "<pre>";
            print_r ($_REQUEST);
            echo "<br />";
            echo "</pre>";
        }
?>

<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<title>Xinha Test</title>
<LINK rel='stylesheet' type='text/css' href='style.css'>
<!-- Begin Xinha HTML Editor -->
<script type='text/javascript'>
    _editor_url  = '/rap_admin/xinha/';  // (preferably absolute) URL (including trailing slash) where Xinha is installed
    _editor_lang = 'en';      // And the language we need to use in the editor.
    _editor_skin = 'titan';   // If you want use a skin, add the name (of the folder) here
</script>
<script type='text/javascript' src='/rap_admin/xinha/XinhaCore.js'></script>
<script type='text/javascript' src='/rap_admin/xinha/new_config.js'></script>
<!-- End Xinha HTML Editor -->

</head>
<body>
<table width='95%' border=1 align=center cellpadding=0 cellspacing=0>
    <td>
    <div id='masthead'>

    </div>
    <table width='100%' border=0 align=center cellpadding=2 cellspacing=0>
        <td align=center colspan=3>



            <center><b>System Email Maintenance</b></center>
        </td></tr>
        <tr><td align=center colspan=3> </td></tr>

        <form method=post>
        <table align=center border=0 cellpading=0 cellspacing=0>
        <tr>
            <td align=right valign=top wrap=nowrap>Email Subject :</td>
            <td valign=top><input type=text size=40 maxlength=255 name=dld_subject value='<?php $dld_subject?>'></td>
            <td valign=top></td>
        </tr>
        <tr>
            <td align=right valign=top wrap=nowrap>Email Message :</td>
            <td valign=top>
                <textarea name=dld_body id=dld_body rows=10 cols=60><?php $dld_body?></textarea>
            </td>
            <td valign=top>

            </td>
        </tr>
        <tr><td align=center colspan=3><hr></td></tr>
        <tr>
            <td></td>
            <td align=center><input type=submit name=submit value='Save Changes'></td>
            <td><input type=hidden name=action value=$action></td>
        </tr>
        </form>
        <tr><td align=center colspan=3> </td></tr>   



</table>
<table width='100%' border=0 align=center cellpadding=0 cellspacing=0>
  <tr>
    <td height=50 align=center style=\"background: url('images/ftrslice.jpg')\">
    <font color='#FFFFFF' size=2 face='Arial, Helvetica, sans-serif'>
    </td>
  </tr>
</table>
</td>
</table>
</body>
</html>
_______________________________

Any help is much appreciated.

Offline

#5 2010-03-15 18:28:34

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: php post textarea problem

    
  <table width='100%' border=0 align=center cellpadding=2 cellspacing=0>
....
  <tr><td align=center colspan=3> </td></tr>
   <form method=post>
   <table align=center border=0 cellpading=0 cellspacing=0>
   <tr>

Incorrect HTML syntax, your HTML is not valid, this will cause it to break.  Make your HTML valid.  Neither form, nor table are valid children of table.


James Sleeman

Offline

#6 2010-03-15 22:30:29

rapper
New member
Registered: 2010-03-15
Posts: 2

Re: php post textarea problem

DOH!!!

James - thanks much.

I can't believe how many times I looked at that and didn't see that I had closed the cell above, rather than letting it contain the form.

This is sweet!  Now I can get it working in the HUGE php page it belongs in.

thx again

Offline

#7 2010-04-26 06:51:11

Neeraj555
Banned
Registered: 2010-04-26
Posts: 1

Re: php post textarea problem

alright....

PHP Code:
<?PHP
///connect
$image_id = $_POST['image'];
$get = mysql_query("SELECT * FROM table WHERE image_id = $image_id");
$row = mysql_fetch_array($get);
if (isset($_POST['submit']))
{
echo $row['image'];  /// actual image not id
}
?>
<html>
<form method='POST' action='<?PHP echo $_SERVER['PHP_SELF']; ?>'>
<textarea>Blah blach</textarea><input type='submit' value='SMILE'>
</form>
im not sure about textarea syntax. sorry.
__________________
HTML,CSS,PHP,Javascript,jQuery,AJAX,mySQL and a very fast typer for Google. Just ask me. Please +rep me if I helped you. Thanks!
Join my new game!


[url=http://www.carpartswarehouse.com/carmodels/CP9/Mercury/Lynx.html]Mercury Lynx Parts[/url]

Offline

Board footer

Powered by FluxBB