Converting form/input in PHP script to be multiline

Discussion in 'PHP' started by mgrohan, Jan 20, 2010.

  1. #1
    Trying to get a input/form in a script to become multiline. At the moment the script will just convert the single string.
    I want to make it into a bulk convert which will convert multiple strings (one on each line)

    Script can be seen in action here: http://idnaconv.phlymail.de/
    Trying to make the simple change so it will convert in bulk, like here: punycoder .com

    <?php
    $encoded = '';
    $decoded = '';
    $add = '';
    header('Content-Type: text/html; charset=UTF-8');
    require_once('idna_convert.class.php');
    $IDN = new idna_convert();
    if (isset($_REQUEST['encode'])) {
        $decoded = isset($_REQUEST['decoded']) ? stripslashes($_REQUEST['decoded']) : '';
        $encoded = $IDN->encode($decoded);
    }
    if (isset($_REQUEST['decode'])) {
        $encoded = isset($_REQUEST['encoded']) ? stripslashes($_REQUEST['encoded']) : '';
        $decoded = $IDN->decode($encoded);
    }
    if (isset($_REQUEST['lang'])) {
        if ('de' == $_REQUEST['lang'] || 'en' == $_REQUEST['lang']) $lang = $_REQUEST['lang'];
        $add .= '<input type="hidden" name="lang" value="'.$_REQUEST['lang'].'" />'."\n";
    } else {
        $lang = 'en';
    }
    ?>
    <!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>phlyLabs Punycode Converter</title>
    <meta name="author" content="phlyLabs">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <table>
       <tr>
        <td align="right">
         <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
          <input type="text" name="decoded" value="<?php echo htmlentities($decoded, null, 'UTF-8'); ?>" size="48" maxlength="255"  /><br />
          <input type="submit" name="encode" value="Encode &gt;&gt;" /><?php echo $add; ?>
         </form>
        </td>
        <td align="left">
         <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
          <input type="text" name="encoded" value="<?php echo htmlentities($encoded, null, 'UTF-8'); ?>" size="48" maxlength="255" /><br />
          <input type="submit" name="decode" value="&lt;&lt; Decode" /><?php echo $add; ?>
         </form>
        </td>
       </tr>
       </table>
    </body>
    </html>
    Code (markup):
    Thanks for any help or direction. +Rep
     
    mgrohan, Jan 20, 2010 IP
  2. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #2
    instead of


    <input type="text" name="decoded" value="<?php echo htmlentities($decoded, null, 'UTF-8'); ?>" size="48" maxlength="255"  />
    PHP:

    Use:
    <textarea name="decoded" cols="28" maxlength="255" rows="7"><?php echo htmlentities($decoded, null, 'UTF-8');</textarea>
    PHP:
    and the same on "encoded"
     
    n3r0x, Jan 20, 2010 IP
  3. f3rd14nt0

    f3rd14nt0 Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    just use textarea. :)
     
    f3rd14nt0, Jan 20, 2010 IP
  4. mgrohan

    mgrohan Active Member

    Messages:
    671
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Yes, i have tried that although only the first term in the text area gets converted.

    Still not working..
     
    mgrohan, Jan 20, 2010 IP