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 6 of 6
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating a simple form that displays field output on same page?

    Ok so I'm not really sure how asp works or if i even need it, but from reading online i think i do. All i want to do is create a simple form for a user to enter their name, submit, and their name is displayed on the same page above the field and submit button. But i want any user that does this, for their name to be added to the list. I would use something like this i think:

    Code:
    <form name="input" action="html_form_action.asp"
    method="get">
    Username: 
    <input type="text" name="user">
    <input type="submit" value="Submit">
    </form>

    And what i want it to look like is something like this, and this would be an example after a few people have used it:


    Name#1
    Name#2

    [TEXT FIELD TO ENTER NAME] [SUBMIT BUTTON]


    after submitting their name, it goes beneath name#2 and so forth. I would imagine this would be pretty simple, if anyone can help me with this i would greatly appreciate it. Thanks.

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    What are you going to use to store the names? This can be a database, a text file, an excel spreadsheet, or an xml file. Otherwise what you want will only work for the individual who is adding the names, and even then as soon as this person closes the page, that info is gone. No one else will see the names.

    Let me know more specifics on how you plan to store the names and I can help you.

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    perhaps using mysql, this is for my phpbb forum but i am using html for this. I have mysql and i assume that would work. Otherwise, whatever will get it to submit the person's name and have it save on the page inside a table for others to see will work.

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    If you are going to use the phpbb forum software, you will be using MySQL. However, you will also be using PHP as your Server-Side language, not ASP.

    To answer your question about how to create a form:

    IN ASP:
    Code:
    <% 
    if request.form("FirstName") <> "" then reply = request.form("FirstName")
    if request.form("LastName") <> "" then reply = reply & request.form("LastName")
    '
    response.write("Thanks for applying, " & reply & vbCrLf)
    response.flush
    response.end
    %>
    IN PHP (untested):

    Code:
    <?php
    if (isset($_REQUEST["FirstName"]) { $reply = $_REQUEST["FirstName"]; }
    if (isset($_REQUEST["LastName"]) { $reply += $_REQUEST["LastName"]; }
    
    echo "Thanks for applying, ".reply;
    ?>

    HTML:
    Code:
    <form method="post" action="myform.asp">  <!-- action may also be myform.php, depending on your Server Side language -->
    First Name: <input type="text" name="FirstName" size="10" /><br />
    Last Name: <input type="text" name="LastName" size="10" /><br />
    <input type="submit" value="Submit" name="B1" />
    </form>

    Mod -- you may want to consider moving this thread over to PHP.
    Last edited by Daemonspyre; 08-08-2007 at 02:20 PM.
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #5
    New Coder
    Join Date
    Aug 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ty for the help. I don't spose a mod could move it? I'lll look, but most forums users can't move threads. So it looks like i have the code for phpbb, just need a sql table to be created and save the data i guess.


    EDIT:

    Parse error: parse error, unexpected '{' in /usr/www/snk/forums/tournament.php on line 21

    I get that^^

    http://pastebin.ca/650197

    that's what i did
    Last edited by hatz; 08-08-2007 at 08:57 PM.

  • #6
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Since you are using that code, try:

    Code:
    <?php
    if (isset($_REQUEST["FirstName"]) $reply = $_REQUEST["FirstName"];
    if (isset($_REQUEST["LastName"]) $reply += $_REQUEST["LastName"];
    
    echo "Thanks for applying, ".reply;
    ?>
    Notice no braces.

    I'm a fairly novice PHP coder myself (but have lots of XP in ASP), that's why I said it was untested.

    If the above doesn't work, you can also try

    Code:
    <?php
    if (isset($_REQUEST["FirstName"]) { 
       $reply = $_REQUEST["FirstName"]; 
    }
    if (isset($_REQUEST["LastName"]) { 
       $reply += $_REQUEST["LastName"]; 
    }
    
    echo "Thanks for applying, ".reply;
    ?>
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.


  •  

    Posting Permissions

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