Results 1 to 7 of 7

Thread: Help with form submissions

  1. #1
    Join Date
    Jul 2007
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with form submissions

    I am wanted to add a form so that when you submit it, it places that information on another page on the website. This may not be a javascript application but I wasnt sure where to start

    Thanks
    Derek M

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Do you want the info to be just displayed, or are you going to end up saving the information. I believe you could just display the form values using javascript, but you would get better results using a server side language such as PHP or ASP. For PHP, you could use something like this (as a basis):
    -------------------------------

    form.html
    Code:
    <html>
    <body>
    
    <form action="submit.php" method="POST">
    
    Field 1: <input type="text" name="testField"> <br>
    Field 2: <input type="text" name="testFieldTwo"> <br>
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>


    submit.php
    Code:
    <?php
    
    echo $_POST['testField'] . "<BR>" . $_POST['testFieldTwo'];
    
    ?>
    Note: The html in my first code example is not valid HTML, but simply an example of the form. In order for this to work properly, you will need to have PHP enabled on your server.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jul 2007
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the quick reply. Yes I do want it displayed on the page. I thought php would work but I wasnt sure. Thank you I will try doing this!!!

    Derek M

  4. #4
    Join Date
    Jul 2007
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    you may be able to hlp me with something else or at least direct me to the right forum. I have about 500 pdf/microsoft word files on my website that I would like people to be able to search a word and find that particular file in my directory and display the results. What would I use for this?

    Derek M

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You would want to use PHP (or; again, any server side language that can access the server's file system) and in turn using some form of Regular Expressions to search the filenames or those documents. As far as reading the files and searching through that, that would be harder to do. I recommend you look at this script:

    http://cj-design.com/products/free_d...jwebsitesearch

    and use that admin area to enter keywords, descriptions, etc of those files to somewhat make it easier on you.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Jul 2007
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default regarding form post method

    do i need to create a file called submit.php and if so what do i need to put in it
    Thanks
    Derek M

  7. #7
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Well, no, but the page that displays what was submitted in the form must be a .php file and must be the file that the form submits to...

    So, you would want to replace submit.php in the action of the form to the name of the php file you want to use.

    In this file, you would want to use $_POST['name_of_form_field'], and any time you're writing php code it needs to be inside <?php ?> tags. Here's an example:

    PHP Code:
    Name: <?php echo $_POST['name']; ?><br />
    Email: <?php echo $_POST['email']; ?><br />
    <!-- etc, etc, etc... -->
    Now, you can get more complicated with the code. Using if/else statements to check if the field was filled in, then echoing accordingly. But this is just a basic introduction.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

Bookmarks

Posting Permissions

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