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

Thread: text box

  1. #1
    New Coder
    Join Date
    Nov 2012
    Location
    chennai
    Posts
    55
    Thanks
    29
    Thanked 0 Times in 0 Posts

    text box

    Hi,
    I did a php code for inserting and updating elements into the database.
    Nw i want to do the coding for, When clicking the submit button, a messagebox with input field get open asking to enter the name.How shall i do this please any1 help me.

  • #2
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts
    You can do that with Javascript instead. At that point you are still waiting for the user to enter some data, so you would want them to do so before sending it off to be processed by your PHP script.

    It may be more appropriate if the name input field is already avaliable to be filled-out. You should bear in mind that a submit button (in the format of a submit button) will usually be expected to submit the page, not progress to another step.

  • Users who have thanked Custard7A for this post:

    gayathri (12-07-2012)

  • #3
    New Coder
    Join Date
    Nov 2012
    Location
    chennai
    Posts
    55
    Thanks
    29
    Thanked 0 Times in 0 Posts
    I can understand. bt still i dont knw where to set the input field in the code. will u please tell it with an example.

  • #4
    Regular Coder Redcoder's Avatar
    Join Date
    May 2012
    Location
    /dev/null
    Posts
    331
    Thanks
    2
    Thanked 47 Times in 46 Posts
    You put Javascript code in HTML code. Then set an event trigger that will cause a message box(or prompt) to appear. Then set your PHP code to process the textbox/messagebox/prompt using $_POST.

    I don't know whether you know any Javascript as you have not stated but check out documentation on Javascript here:

    http://www.w3schools.com/js/default.asp

    PHP $_POST:

    http://www.w3schools.com/php/php_post.asp

    http://php.net/manual/en/reserved.variables.post.php

    You have not stated what exactly you know or don't know.

  • Users who have thanked Redcoder for this post:

    gayathri (12-10-2012)

  • #5
    New Coder
    Join Date
    Nov 2012
    Location
    chennai
    Posts
    55
    Thanks
    29
    Thanked 0 Times in 0 Posts
    I knw little bit in java script.
    the following is a piece of my code. In this i dnt knw were to add to get input field i text box

    Code:
    <html>
    <head>
    <title>QBank</title>
    </head>
    <body>
    <form name="Board" action="boards1.php" method="post">
    id :<input type="text" name="sid">
    name : <input type="text" name="sname"><br>
    <table border="1">
    <tr><th>Id</th><th>Name</th></tr>
    <?
    include("config.php");
    $sql1="select * from Boards order by id";
    $res1=mysql_query($sql1);
    while($row = mysql_fetch_array($res1))
    {
    echo "<tr><td>$row[0]</td><td>$row[1]</td></tr>";
    }
    ?>
    </table>
    <input type="submit" value="Save" name="insert" />
    <input type="submit" value="update" name="update"/>
    <input type="submit" value="clear" name="clr"/>
    </form>
    </body>
    </html>
    Code:
    <?php
    include("config.php");
    $id=$_POST['sid'];
    $name=$_POST['sname'];
    $update=$_POST['update'];
    //$save=$_POST['insert'];
    echo $update." ".$id." ".$name." ";
    /*if(($sav=="Save"))
    {
    echo "hai";
    
    $sql="insert into Boards(id,name)values($id,'$name')";
    $res=mysql_query($sql);
    }*/
    if(($update=="update"))
    {
    //echo "hai1";
    $sql1="update Boards set name='$name' where id=$id";
    echo $sql1;
    $res1=mysql_query($sql1);
    if($res1)
    echo "<script>($res1)</script>";
    }
    ?>
    any1 please tell me

  • #6
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts
    You should just create another <input type="text"... Creating a pop-up box in Javascript to gain additional data is quite flawed, without efficient fall-backs at least. Some people may have Javascript disabled and your form will then break.

  • Users who have thanked Custard7A for this post:

    gayathri (12-10-2012)

  • #7
    New Coder
    Join Date
    Nov 2012
    Location
    chennai
    Posts
    55
    Thanks
    29
    Thanked 0 Times in 0 Posts
    Thanks Custard7A and Redcoder for ur useful post. With ur ideas i did my code. And its working too. thanks


  •  

    Posting Permissions

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