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 5 of 5

Thread: Locked text Box

  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Locked text Box

    Ive created a insert form behaviour in php to mysql database, i one text box i want to let the user insert text and submit the form.

    However i want to insert "index.php?action=", before the users entered text, and submit the whole thing as one field,

    eg, "index.php?action=ENTEREDTEXT"

    ANY IDEAS!!

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    just add the string before you put it into the db
    PHP Code:
    <?
    $_POST
    [$textfield] = 'index.php?action=' $_POST[$textfield] ;
    $sql "INSERT INTO $table SET $textfield='{$_POST[$textfield]}'";// etc
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Welcome here !

    Just add the i"ndex.php?action=" when you process the form?
    Like
    $text= 'index.php?action='. $_POST['text'];

    or if the text you want to prefix isn't always the same, then store that inside a hidden formfield, and dosomething like

    $text= $_POST['prefix'] . $_POST['text'];

    <edit>posts crossed. Seams we're both on the same track</edit>
    Last edited by raf; 04-21-2004 at 03:21 PM. Reason: posts crossed
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #4
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Insert Server Behavior

    I have a list box which is set up for multiple selections. I have the insert Server Behavior set up for the list box fields. If the user selects more than one item from the list box and then submits only the first item selected is being inserted into the table. Can I do multiple inserts into a table using a list box?

  • #5
    New Coder
    Join Date
    May 2003
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, the easiest way in my opinion is to make the HTML form names arrays:

    ie: name="whatever[]"

    Then in your PHP code, best way to insert or update is using a foreach function:

    PHP Code:
    foreach($_POST['whatever'] as $key => $val) {
      
    $sql "INSERT into Table (`first_column`) VALUES ('{$val}')";
      
    mysql_query($sql);

    Of course you will have several arrays and so you can reference them all in the same foreach by doing the following:
    PHP Code:
    foreach($_POST['whatever'] as $key => $val) {
      
    $sql "INSERT into Table (`first_column`,`second_column`) VALUES ('{$val}','{$_POST['second_form_field'][$key]}')";
      
    mysql_query($sql);

    cpCommerce - Finally a template based open-source e-commerce solution


  •  

    Posting Permissions

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