Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: Notice: Undefined variable: _post in mit textarea

  1. #1
    Join Date
    Aug 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Notice: Undefined variable: _post in mit textarea

    Die Fehlermeldung : Notice: Undefined variable: _post in
    (deutet auf die Zeile mit <?= $_POST['form_prtext'] ?> in untenstehendem Code)

    tritt nur auf, wenn ich im Formular textarea verwende. In der Mysql-Tabelle ist das Feld für den Inhalt des Textfelds mit varchar definiert.
    Wenn ich ein inputfeld verwende, tritt der Fehler nicht auf.

    Code:
    Medium:<br>
    <input name="form_medium" type="text" class="form_text" size="40" maxlength="40" value="<?= $_POST['form_medium'] ?>">
    <br>
    Pressetext:<br>
    <textarea name="form_prtext" cols="40" rows="15"> <?= $_POST['form_prtext'] ?></textarea>
    <br>

    Ich habe oben im Script auch
    if (!isset($_POST['form_prtext'])) $_POST['form_prtext'] = '';
    also ist die Variable definiert!

    Keine Ahnung was der Fehler sein könnte...

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Not sure if this will fix your problem as I don't speak German, but try the following.
    Übersetzt auf Google: Nicht sicher, ob dies Ihr Problem zu beheben, als ich kein Deutsch sprechen, aber versuchen Sie Folgendes.
    Code:
    <br>
    <input name="form_medium" type="text" class="form_text" size="40" maxlength="40" value="<?php echo (isset($_POST['form_medium'])) ? $_POST['form_medium'] : ""; ?>">
    <br>
    Pressetext:<br>
    <textarea name="form_prtext" cols="40" rows="15"><?php echo (isset($_POST['form_prtext'])) ? $_POST['form_prtext'] : ""; ?></textarea>
    <br>

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    _post != _Post
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    John, where do you see "_post" in the code above? I just see it in the error message, but I don't know where it's coming from.

    Also, it shouldn't be '_post' or '_Post', but always '_POST'. PHP is case sensitive for this.


    Losj, hier spricht man nur Englisch. Können Sie Englisch sprechen? Sie werden keine antworten auf Deutsch bekommen. (Ja, ich kann ein bisschen Deutsch sprechen, aber nicht um PHP oder Programmierung zu sprechen. Also ist es besser, dass alle verstanden können.) Aber, willkommen bei Dynamic Drive!
    Last edited by djr33; 08-20-2012 at 08:48 AM.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Aug 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default message in english

    The error message : Notice: Undefined variable: _post in
    (points to the <?= $_POST['form_prtext'] ?> in below Code)

    only if I use textarea in the form. (In mysql table the field for the content is varchar)
    If I use a input instead of textarea there is no mistake

    Code:
    Medium:<br>
    <input name="form_medium" type="text" class="form_text" size="40" maxlength="40" value="<?= $_POST['form_medium'] ?>">
    <br>
    Pressetext:<br>
    <textarea name="form_prtext" cols="40" rows="15"> <?= $_POST['form_prtext'] ?></textarea>
    <br>

    I have defined
    if (!isset($_POST['form_prtext'])) $_POST['form_prtext'] = '';
    , the variable is defined

    no idea what the mistake is. .

  6. #6
    Join Date
    Aug 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Nile View Post
    Not sure if this will fix your problem as I don't speak German, but try the following.
    Übersetzt auf Google: Nicht sicher, ob dies Ihr Problem zu beheben, als ich kein Deutsch sprechen, aber versuchen Sie Folgendes.
    Code:
    <br>
    <input name="form_medium" type="text" class="form_text" size="40" maxlength="40" value="<?php echo (isset($_POST['form_medium'])) ? $_POST['form_medium'] : ""; ?>">
    <br>
    Pressetext:<br>
    <textarea name="form_prtext" cols="40" rows="15"><?php echo (isset($_POST['form_prtext'])) ? $_POST['form_prtext'] : ""; ?></textarea>
    <br>
    There is no mistake for the input fields! All variales have been defined in the script.
    The strange is that if I o not decleare one variable for a inputfield, then the error message says more than post, but the whole variable is named...

  7. #7
    Join Date
    Aug 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Nile View Post
    Not sure if this will fix your problem as I don't speak German, but try the following.
    Übersetzt auf Google: Nicht sicher, ob dies Ihr Problem zu beheben, als ich kein Deutsch sprechen, aber versuchen Sie Folgendes.
    Code:
    <br>
    <input name="form_medium" type="text" class="form_text" size="40" maxlength="40" value="<?php echo (isset($_POST['form_medium'])) ? $_POST['form_medium'] : ""; ?>">
    <br>
    Pressetext:<br>
    <textarea name="form_prtext" cols="40" rows="15"><?php echo (isset($_POST['form_prtext'])) ? $_POST['form_prtext'] : ""; ?></textarea>
    <br>
    there is no error message for the code with the input field! but I try to declare the variable just before use as you do. I declared everx variable in the beginning of the script

  8. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Could you show us all of your code so that we can see anything that may of been done wrong? Also - when showing us errors, please copy and paste. Thanks

  9. #9
    Join Date
    Aug 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default all the code

    Quote Originally Posted by Nile View Post
    Could you show us all of your code so that we can see anything that may of been done wrong? Also - when showing us errors, please copy and paste. Thanks

    PHP Code:
    <?PHP

    if(!isset($_SESSION))
    {
    session_start();
    }
    if (!
    $_SESSION['userID']) {
      
    header("Location: http://".$_SERVER['HTTP_HOST']
                              .
    dirname($_SERVER['PHP_SELF'])
                              .
    "/login.php");
      exit;
    }

    if (!isset(
    $_POST['form_datum'])) $_POST['form_datum'] = '';
    if (!isset(
    $_POST['form_medium'])) $_POST['form_medium'] = '';
     if (!isset(
    $_POST['form_prtext'])) $_POST['form_prtext'] = '';
     if (!isset(
    $status)) $status '';

    if (isset(
    $_POST['upload']))  {
      if (isset(
    $_POST['form_datum']) && ($_POST['form_medium']) &&  ($_POST['form_prtext']))

       {
            
    $sql "INSERT INTO pressetexte (datum, medium, pressetext) VALUES (
                    '"
    .$_POST['form_datum']."',
                    '"
    .$_POST['form_medium']."',
                    '"
    .$_POST['form_prtext']."'
                   )"
    ;
            
    $result mysql_query($sql);
            if(
    $result) {
              
    $status "...eingetragen";
                    unset(
    $_POST);
        }
        else {
                
    $status "...fehlgeschlagen '".mysql_error()."'";
        }
      }
      else {
              
    $status '...Fehler! Fehlende Daten ';
      }
    }
    ?>

    <script language="javascript">
    function openWindow(url) {
    var win;
    win = window.open(url,'Druckversion','width=500,height=400, scrollbars=yes, menubar=no');
    win.focus();
    }
    </script>

    <h2>Pressetext <?=$status?></h2>

    <form action="<?= $_SERVER['REQUEST_URI'?>" method="post" enctype="multipart/form-data" name="pressetexte">
      Datum:<br>
      <input name="form_datum" type="text" class="form_text" size="30" maxlength="30" value="<?= $_POST['form_datum'?>">
      <br>
      Medium:<br>
      <input name="form_medium" type="text" class="form_text" size="40" maxlength="40" value="<?= $_POST['form_medium'?>">
      <br>
      Pressetext:<br>
      <textarea name="form_prtext" cols="40" rows="15"> <?= $_POST['form_prtext'?></textarea>
      <br>

      <p><input type="submit" name="upload" value="Upload"></p>
    </form>
    <p>&nbsp;</p>
    <table width="650" border="0" cellspacing="1" cellpadding="5" bgcolor="#CCCCCC">
      <?PHP
      $sql 
    "SELECT id, datum, medium, pressetext FROM pressetexte ORDER by id ASC";
      
    $result mysql_query($sql) or die(mysql_error());
      while (
    $row mysql_fetch_assoc($result)){
      echo 
    '<tr>';
        echo 
    '<td width="70" bgcolor="white" align="center">'.$row['datum'].'</td>';
        echo 
    '<td width="130" bgcolor="white" align="center">'.$row['medium'].'<br /></td>';
        echo 
    '<td width="430" bgcolor="white" align="center">'.$row['pressetext'].'<br /></td>';

            echo 
    '<td width="20" bgcolor="white" align="center"><a href="javascript:openWindow(\'pressetext_edit.php?id='.$row['id'].'\');">edit</a></td>';
            echo 
    '</tr>';
      }
      
    ?>
    </table>
    Thanks for the help
    Last edited by jscheuer1; 08-20-2012 at 02:35 PM. Reason: Format

  10. #10
    Join Date
    Aug 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    And here the complete error report:
    Notice: Undefined variable: _post in /srv/www/vhosts/...../Admin/pressetext.php on line 61

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •