Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    textfield as part of a command

    Greetings

    I'm newbie to php. I am trying to add a textbox value as a part of a command each time i press a "Submit" button.
    Can someone help me?
    Thanx in advance.

  • #2
    Regular Coder
    Join Date
    Jul 2009
    Posts
    187
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Could you explain a little more I don't get what you mean?

  • #3
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    thanxs for your answer

    Well, i created a php page to controll my lpt port. it works but there are so many values (255), so i cannot have 255 buttons, each for a value.

    Here is my page


    <?php
    {
    if (isset($_POST['up']))
    shell_exec("sudo /var/www/html/up.sh");
    }
    if (isset($_POST['right']))
    {
    shell_exec("sudo /usr/local/bin/parashell 0x378 0");
    }
    if (isset($_POST['down']))
    {
    shell_exec("sudo /var/www/html/down.sh");
    }
    if (isset($_POST['left']))
    {
    shell_exec("sudo /usr/local/bin/parashell 0x378 254");
    }
    ?>
    <HTML>
    <HEAD><TITLE>LPT Control</TITLE>
    <style type="text/css">
    <!--
    .style1 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: bold;
    }
    body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #0033CC;
    }
    body {
    background-color: #CCCCCC;
    }
    -->
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></HEAD>
    <BODY>
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">

    <p class="style1">LPT Control
    <input type='submit' name='up' value="Up">
    <input type='submit' name='down' value='Down'>
    </p>
    <p>
    <INPUT type='submit' name='right' value='All Zero'>
    </p>
    <p>
    <INPUT type='submit' name='left' value='All One'>
    </p>
    <p><INPUT type='submit' name='left2' value='Value Input'>
    <input name="textfield" type="text" value="">
    </p>
    </form>
    </body></html>


    i want to create a text field to write the desired value ( 0 - 255 )
    and by pressing a "Submit" button the value in the text box takes place in the shell_exec("sudo /usr/local/bin/parashell 0x378 XXX"); command and execute ( XXX = value 0 - 255)
    Sorry for my bad english....

  • #4
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    OK well lets say the textarea name is name = " textarea "

    The code would be something like

    PHP Code:
    <?php
    if ( isset ( $_POST['textarea'] ) )
    {
        if (
    in_array($_POST['textarea'], range(0,255)))
        {
            
    shell_exec("sudo /usr/local/bin/parashell 0x378 " . (int) $_POST['textarea']);    
        }
    }
    ?>
    This checks if the textarea post data was sent, checks if the number is w number between 0-255, then executes the command.
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • Users who have thanked Zangeel for this post:

    btigas (09-14-2009)

  • #5
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Zangeel
    Thank you very much for your answer
    I will try this first thing in the morning ( its 1:15 am over here)

  • #6
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Unfortunately this error appears

    Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /var/www/html/test7.php on line 20

    <?php
    {
    if (isset($_POST['up']))
    shell_exec("sudo /var/www/html/up.sh");
    }
    if (isset($_POST['right']))
    {
    shell_exec("sudo /usr/local/bin/parashell 0x378 0");
    }
    if (isset($_POST['down']))
    {
    shell_exec("sudo /var/www/html/down.sh");
    }
    if (isset($_POST['left']))
    {
    shell_exec("sudo /usr/local/bin/parashell 0x378 254");
    }
    if ( isset ( $_POST['textarea'] ) )
    {
    if (in_array($_POST['textarea'], range(0,255)))
    {
    shell_exec("sudo /usr/local/bin/parashell 0x378 " . (int) $_POST['textarea']);
    }
    }
    ?>
    <HTML>
    <HEAD><TITLE>LPT control</TITLE>
    <style type="text/css">
    <!--
    .style1 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: bold;
    }
    body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #0033CC;
    }
    body {
    background-color: #CCCCCC;
    }
    -->
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></HEAD>
    <BODY>
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">

    <p class="style1">LPT Control
    <input type='submit' name='up' value="UP">
    <input type='submit' name='down' value='DOWN'>
    </p>
    <p>
    <INPUT type='submit' name='right' value='All 0'>
    </p>
    <p>
    <INPUT type='submit' name='left' value='All 1'>
    </p>
    <p><INPUT type='submit' name='valueadd' value='Value Insert'>
    <input name="textarea" type="text" >
    <p>
    <p>
    </form>
    </body></html>


    Help Needed!!!

  • #7
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Solved!!

    Zangeel
    Thank you very much
    Your Answer was correct


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •