Re: how to insert PHP into confirrmation page
| From: | Aziz Saleh | Date: | Mon, 01 Oct 2018 02:47:50 +0000 |
| Subject: | Re: how to insert PHP into confirrmation page | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326571@lists.php.net to get a copy of this message | ||
On Sun, Sep 30, 2018 at 10:42 PM sh <hosayuki@ybb.ne.jp> wrote:
> Hello
>
> I am a new member. I have a question about form page and confirmation page.
>
> The question is how to get word count in confirmation page from form page
> by PHP. The program is as below which is part of whole page.
>
>
>
> Function of getting word count is: str_word_count($_POST["sentence"]
>
> I am waiting for fast answer from a member.
>
>
>
> [form page, by html]
>
> <form name="namae" method="post"
> action="2contact_mail.php">
>
> <table class="formTable">
>
> <tr>
>
> <th>language combination</th>
>
> <td><select name=" language combination ">
>
> <option value="" selected> ----</option>
>
> <option value="japanese→english"> japanese→english </option>
>
> <option value=" english→japanese "> english→japanese </option>
>
> </select></td>
>
> <td><input size="30" type="hidden" name="word_count"
> /></td>
>
> </tr>
>
> <tr>
>
> <th> sentence </th>
>
> <td><textarea name="sentence" rows="4"
> cols="40"></textarea></td></tr>
>
> </table>
>
>
>
> [confirmation page, by php]
>
>
>
> function confirmOutput($arr){
>
> global $hankaku,$hankaku_array;
>
> $html = '';
>
> foreach($arr as $key => $val) {
>
> $out = '';
>
> if(is_array($val)){
>
>
>
> foreach($val as $key02 => $item){
>
>
>
> if(is_array($item)){
>
> $out .= connect2val($item);
>
> }else{
>
> $out .= $item . ', ';
>
> }
>
> }
>
> $out = rtrim($out,', ');
>
> }else{ $out = $val; }
>
> if(get_magic_quotes_gpc()) { $out = stripslashes($out); }
>
> $out = nl2br(h($out));
>
> $key = h($key);
>
> ------
> I tried as follows:
> I added:
> $out .= str_word_count($_POST["sentence"]).;
>
> Above
> $out = nl2br(h($out));
>
>
>
> But in all columns word count was added. I need word count only in
> textarea.
>
>
>
>
>
> Saneyuki Hori
>
>
>
Here is how string concatenation works in PHP:
$a = 'Test';
$a .= '123';
echo $a; // Test123
In your example you are adding the word count to $out. This would work:
$number_count = str_word_count($_POST["sentence"]);
Now that variable $number_count has the word count you are looking for.