Textarea function php pass data

Asked

Viewed 891 times

1

I have a question about how I can be passing the value of a textarea to a php function.

I have the following function:

function _dup($cclist) {
        for ($i = 0; $i < count($cclist); $i++) {
                $ccnum = info($cclist[$i]);

                if (is_array($ccnum)) {
                        $cc = $ccnum['num'];
                        for ($j = $i + 1; $j < count($cclist); $j++) {
                                if (inStr(str_replace("-", "", str_replace(" ", "", $cclist[$j])), $cc))
                                        $cclist[$j] = "";
                        }
                }
        }

        foreach ($cclist as $i => $cc)
                if ($cc == "")
                        unset($cclist[$i]);

        $ok = array_values($cclist);
        return $ok;
}

And to run the script I have this other function:

function check($ccnum, $ccmonth, $ccyear, $cccvv) {
        $ccline = $ccnum."|".$ccmonth."|".$ccyear."|".$cccvv;
        $action = new Run();
        $action->addToCart();
        $action->CCLINE = $ccline;
        return $action->checkOut();
}

texarea will receive the value nome|cpf|mae|data so that function check can make your validation.

HTML

<form action="" method=post name=f> <textarea wrap="off" name=cclist cols=90 rows=20> </textarea><br> <br> <input style="width:100px" class="button" type=submit name=submit size=10 value="Valida"> </form> 
  • The textarea is in a form?

  • <form action="" method=post name=f> <textarea wrap="off" name=cclist cols=90 Rows=20> </textarea><br> <br> <input style="width:100px" class="button" type=Submit name=Submit size=10 value="Valida"> </form>

  • Edit your question by placing this code (there is an edit button just up here)

  • Edited . could help me now ?

  • It would only be to submit the form to a PHP page that called the function. You’ve tried this?

  • Goes blank .

  • 1

    Hi, I don’t know if this was just during the creation of the question, or if you did the same in the script, but put the aspas in the attributes html, and another thing is, where does the function _dup is called ? And what is her real function in the script ? I don’t really know what the code is about, but I get the impression that it’s a filter for certain data entered in the textarea. I await return.

Show 2 more comments

1 answer

1

Your doubt is confused, but answering the question:

how can I be passing the value of a textarea to a php. Would that be:

HTML

<form action="" method=post name=f>
<textarea wrap="off" name=cclist cols=90 rows=20> </textarea><br> <br>
<input style="width:100px" class="button" type=submit name=submit size=10 value="Valida"> 
</form> 

PHP

<?php
function nomeFuncao(){
   $cclist =  $_POST['cclist'];

Then to separate the values name|Cpf|mae|date if they’re separated by | it’s easy:

    $cclist_separados = explode("|", $cclist);
    print_r($cclist_separados);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.