Hello, I have an input line that I would like to convert to a text area. Can someone please help me? Here is the input:

<input name="teacher<?php echo $rrows['id']; ?>" id="teacher<?php echo $rrows['id']; ?>" type="text" size="10" value="<?php echo $rrows['teacher']; ?>" >

This works great as an input. It allows me to retrieve data from the database, edit it and save it back to the database, but now I need to do the same operation with a bunch of text.

Thanks for your help, okrobie

    <textarea name="teacher<?php echo $rrows['id']; ?>" id="teacher<?php echo $rrows['id']; ?>"><?php echo $rrows['teacher']; ?></textarea>
    

      Thanks Kirk, That looks like it should work but somehow it's not complete. With that line in place I can retrieve data from the database but when I go to save it, it writes the word "undefined" into the database and deletes the original text. I know you are on the right track. Thanks again, okrobie

        Why would you need to change it if you only allow 10 chars input?

        Also, show the code to do the saving, that is probably where your problems lie.

          Thanks mrbaseball34, Here is the whole form as it stands right now. The final size for the textarea will be cols="80" rows="5". I don't know much about the javascript so that could be part of the problem. Thanks again, okrobie

          <form name="edit<?php echo $rrows['id']; ?>" action="" method="get"> 
          			<input type="hidden" name="id<?php echo $rrows['id']; ?>" id="id<?php echo $rrows['id']; ?>" value="<?php echo $rrows['id']; ?>"><br>
          			First Name: <input name="first_name<?php echo $rrows['id']; ?>" id="first_name<?php echo $rrows['id']; ?>" type="text" size="10" value="<?php echo $rrows['first_name']; ?>" >
          			Last Name: <input name="last_name<?php echo $rrows['id']; ?>" id="last_name<?php echo $rrows['id']; ?>" type="text" size="10" value="<?php echo $rrows['last_name']; ?>" >
          			User Name: <input name="user_name<?php echo $rrows['id']; ?>" id="user_name<?php echo $rrows['id']; ?>" type="text" size="10" value="<?php echo $rrows['user_name']; ?>" >
          			<br><br>
          			User Email:<input id="user_email<?php echo $rrows['id']; ?>" name="user_email<?php echo $rrows['id']; ?>" type="text" size="30" value="<?php echo $rrows['user_email']; ?>" >
          			Level: <input id="user_level<?php echo $rrows['id']; ?>" name="user_level<?php echo $rrows['id']; ?>" type="text" size="5" value="<?php echo $rrows['user_level']; ?>" > 1->Parent,2->Teacher,5->Admin
          			<br><br>
          			New Password: <input id="pass<?php echo $rrows['id']; ?>" name="pass<?php echo $rrows['id']; ?>" type="text" size="20" value="" > (leave blank)
          
          		<textarea name="teacher<?php echo $rrows['id']; ?>" id="teacher<?php echo $rrows['id']; ?>"><?php echo $rrows['teacher']; ?></textarea>
          
          		Homework: <br> <textarea name="homework<?php echo $rrows['id']; ?>" cols="80" rows="5"  id="homework<?php echo $rrows['id']; ?>">   </textarea><br><br>
          		Projects: <br> <textarea name="projects<?php echo $rrows['id']; ?>" cols="80" rows="5"  id="projects">  <?php echo $rrows['projects']; ?> </textarea><br><br>
          		Schedules:<br>  <textarea name="schedules<?php echo $rrows['id']; ?>" cols="80" rows="5"  id="schedules">  <?php echo $rrows['schedules']; ?> </textarea><br><br>
          		News & Information:<br>  <textarea name="news<?php echo $rrows['id']; ?>" cols="80" rows="5"  id="news">  <?php echo $rrows['news']; ?> </textarea><br>
          
          		<br><br>
          
          		<input name="doSave" type="button" id="doSave" value="Save" 
          		onclick='$.get("do.php",{ cmd: "edit", pass:$("input#pass<?php echo $rrows['id']; ?>").val(),first_name:$("input#first_name<?php echo $rrows['id']; ?>").val(),last_name:$("input#last_name<?php echo $rrows['id']; ?>").val(),user_level:$("input#user_level<?php echo $rrows['id']; ?>").val(),user_email:$("input#user_email<?php echo $rrows['id']; ?>").val(),user_name: $("input#user_name<?php echo $rrows['id']; ?>").val(),teacher:$("input#teacher<?php echo $rrows['id']; ?>").val(),id: $("input#id<?php echo $rrows['id']; ?>").val() } ,function(data){ $("#msg<?php echo $rrows['id']; ?>").html(data); });'> 
          		<a  onclick='$("#edit<?php echo $rrows['id'];?>").hide();' href="javascript:void(0);">close</a>
          	  </form>
          

            Also, here is the do.php which is referenced:

            <?php 
            include 'dbc.php';
            session_start();
            if(!checkAdmin()) {
            header("Location: login.php");
            exit();
            }
            
            $ret = $_SERVER['HTTP_REFERER'];
            
            foreach($_GET as $key => $value) {
            	$get[$key] = filter($value);
            }
            
            if($get['cmd'] == 'approve')
            {
            mysql_query("update users set approved='1' where id='$get[id]'") or die(mysql_error());
            $rs_email = mysql_query("select user_email from users where id='$get[id]'") or die(mysql_error());
            list($to_email) = mysql_fetch_row($rs_email);
            
            $host  = $_SERVER['HTTP_HOST'];
            $host_upper = strtoupper($host);
            $login_path = @ereg_replace('admin','',dirname($_SERVER['PHP_SELF']));
            $path   = rtrim($login_path, '/\\');
            
            $message = 
            "Thank you for registering with the Holy Family Catholic School website. Your account has been activated...
            
            *****LOGIN LINK*****\n
            http://$host$path/login.php
            
            Thank You
            
            Administrator
            $host_upper
            ______________________________________________________
            THIS IS AN AUTOMATED RESPONSE. 
            ***DO NOT RESPOND TO THIS EMAIL****
            ";
            
            @mail($to_email, "User Activation", $message,
            "From: \"Member Registration\" <auto-reply@$host>" );
            
            
            
             echo "Active";
            
            
            }
            
            if($get['cmd'] == 'ban')
            {
            mysql_query("update users set banned='1' where id='$get[id]'");
            
            //header("Location: $ret");  
            echo "yes"; exit(); } /* Editing users*/ if($get['cmd'] == 'edit') { /* Duplicate user name check */ $rs_usr_duplicate = mysql_query("select count(*) as total from `users` where `user_name`='$get[user_name]' and `id` != '$get[id]'") or die(mysql_error()); list($usr_total) = mysql_fetch_row($rs_usr_duplicate); if ($usr_total > 0) { echo "Sorry! user name already registered."; exit; } /* Duplicate email check */ $rs_eml_duplicate = mysql_query("select count(*) as total from `users` where `user_email`='$get[user_email]' and `id` != '$get[id]'") or die(mysql_error()); list($eml_total) = mysql_fetch_row($rs_eml_duplicate); if ($eml_total > 0) { echo "Sorry! user email already registered."; exit; } /* Now update user data*/ mysql_query(" update users set
            `first_name` = '$get[first_name]', `last_name` = '$get[last_name]', `user_name` = '$get[user_name]', `user_email` = '$get[user_email]', `user_level` = '$get[user_level]', `teacher` = '$get[teacher]', `homework` = '$get[homework]', `projects` = '$get[projects]', `schedules` = '$get[schedules]', `news` = '$get[news]' where `id`='$get[id]'") or die(mysql_error()); //header("Location: $ret"); if(!empty($get['pass'])) { $hash = PwdHash($get['pass']); mysql_query("update users set `pwd` = '$hash' where `id`='$get[id]'") or die(mysql_error()); } echo "changes done"; exit(); } if($get['cmd'] == 'unban') { mysql_query("update users set banned='0' where id='$get[id]'"); echo "no"; //header("Location: $ret");
            // exit(); } ?>

              betwen these two lines:

              $ret = $_SERVER['HTTP_REFERER'];
              
              foreach($_GET as $key => $value) {
              

              place this:

              var_dump($_GET);
              exit;
              

              Then you will see if the text from the textarea is actually getting to your processing script correctly.

                I placed the code as you said but I am getting the following error message:

                array(9) { ["cmd"]=>  string(4) "edit" ["pass"]=>  string(0) "" ["first_name"]=>  string(5) "Actual First Name" ["last_name"]=>  string(6) "Actual Last Name" ["user_level"]=>  string(1) "2" ["user_email"]=>  string(23) "Actual Email Address" ["user_name"]=>  string(7) "okrobie" ["teacher"]=>  string(9) "undefined" ["id"]=>  string(2) "55" } 
                

                  The text going to the database is still "undefined"

                  And by the way, Thanks

                    This shows that it is not being passed correctly in from form:

                    ["teacher"]=>  string(9) "undefined"
                    

                      Hi mrbaseball34, Thanks, that looks like your diagnostics worked out. Where do we go from here?

                        5 days later

                        I have the solution. The save line for teacher has to be like this:

                        teacher:$("textarea#teacher<?php echo $rrows['id']; ?>").val()
                        

                        The word textarea must replace the word input.

                        Then it works using Kirks textarea line. Thanks Kirk

                        Thanks mrbaseball34.

                        Regards, okrobie

                          Write a Reply...