Connecting Tech Pros Worldwide Help | Site Map

Printing AIML response in a textarea in PHP

Newbie
 
Join Date: Jan 2007
Location: Dublin
Posts: 3
#1: Jan 21 '07
Hi,

This is my first post. I am currently learning PHP and am trying to combine it with AIML in order to create a chatbot that prints its replies into a textarea.(named "Answerfield")

At the moment, I only know how to print the output within a new Internet Explorer or Firefox windows.

I am looking for a way to edit the PRINT command so that the output can appear in the textarea but no luck so far. Any ideas would be really welcome.

Here is my PHP code:

[PHP]

if (isset($HTTP_POST_VARS['input'])){

$numselects=0;

// Start the session or get the existing session.

session_start();
$myuniqueid=session_id();

// Here is where we get the reply.

$botresponse=replybotname($HTTP_POST_VARS['input'],$myuniqueid,$HTTP_POST_VARS['botname']);

// Print the chatbot response

print "<B>ANSWER : " . $botresponse->response . "<BR></b>";


?>

<html>
<head>
<body bgcolor="gold" text="#000000">
<title>Feedback</title>
</head></body></html>

<? [/PHP]


Thanks in advance
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Jan 21 '07

re: Printing AIML response in a textarea in PHP


You want to print the data in your textarea. What textarea? There is no textarea in your code. Please show us.

Ronald :cool:
Newbie
 
Join Date: Jan 2007
Location: Dublin
Posts: 3
#3: Feb 16 '07

re: Printing AIML response in a textarea in PHP


Thanks a lot for your reply and my apologies for the delay, I couldn't log back in to the site.
Here is the code with showing the textarea.
There must be a way to tell PHP to print within the textarea declared as "Answerfield" at the bottom of the page. I am learning php at the moment and have very little experience :

[PHP]if (isset($HTTP_POST_VARS['input'])){
$numselects=0;
$myuniqueid=session_id();

$botresponse=replybotname($HTTP_POST_VARS['input'],$myuniqueid,$HTTP_POST_VARS['botname']);

print "<B>ANSWER : " . $botresponse->response . "<BR></b>"?>

<html>
<head>
<body bgcolor="lightblue" text="#000000">
<title>Feedback</title>
</head></body></html>

<form name="form1" method="post" action="talk.php">

<select name="botname">
<?
foreach ($availbots as $onebot){
print "<option value=\"$onebot\">$onebot</option>";
}
?>
</select><BR>

Type your question here: <input type="text" name="input" size="54">

<input type="submit" name="Submit" value="Submit">
</form>

<form>
Answer: <textarea name="Answerfield" cols="60"></textarea>
<input type="submit" name="GoToNextLecture" value="Next Lecture">
</form>

</body>
</html>

<?

}

?>[/PHP]

Thank you in advance, Any help is greatly appreciated
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#4: Feb 16 '07

re: Printing AIML response in a textarea in PHP


Just echo the PHP variable (e.g. $mytext) you want to show in the textarea, like this:

[php]
Answer: <textarea name="Answerfield" cols="60"><?php echo $mytext; ?></textarea>
[/php]

Ronald :cool:
Newbie
 
Join Date: Jan 2007
Location: Dublin
Posts: 3
#5: Feb 23 '07

re: Printing AIML response in a textarea in PHP


Quote:

Originally Posted by ronverdonk

Just echo the PHP variable (e.g. $mytext) you want to show in the textarea, like this:

[php]
Answer: <textarea name="Answerfield" cols="60"><?php echo $mytext; ?></textarea>
[/php]

Ronald :cool:


Thanks a million for your reply Ronald!! I really appreciate your valuable advice! Im gonna give this shot and will let you know how I get on!
Reply