SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I have made a form that I would like to submit certain information. I set it up to it emails all the info to a certain email address. Now that all works perfectly. What I need to find out is how to install a cgi script on my web server so that I can designate what page the user is sent to depending on wether the information is correct or not. I would like a "Info sent" page and a "Error w/ info" page. Any help is greatly appreciated. Thank you...

  2. #2
    SitePoint Addict
    Join Date
    Oct 2000
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I follow your question, Brad, you'd probably be wisest to do this within the mailing script itself -- rather than with some separate means of redirection.

    In brief, upon accepting the form information, evaluate it as correct or in error, and redirect to different pages based on the evaluation.

    As this is posted in the Client-Side Scripting forum, I will note that you can indeed do this with JavaScript, client-side (evaluating the form fields).

    However, I'd really suggest rolling this all in CGI, as the scripting would actually be easier, more flexible, and more reliable.



    [Edited by etLux on 11-17-2000 at 04:13 PM]

  3. #3
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Brad,

    You can set a form's action conditionally as follows:

    function chkFields(formObj)
    {
    var isOk = true;

    ....validation checks....if fail, isOk = false...

    formObj.action = (isOk) ? 'goodpage.html' : 'badpage.html';
    }

    You only need to omit the 'action' attribute from the form tags and check the fields upon submission (either through onSubmit or onClick, dependent upon whether you are using a submit or regular button).

    If this is not what you are looking for, I will move this thread to the server-side forum.

    Vinny

    Where the World Once Stood
    the blades of grass
    cut me still

  4. #4
    SitePoint Addict
    Join Date
    Oct 2000
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As pointed out in both Vinny's post and my own above, this can be accomplished fairly straightforwardly in JavaScript.

    My suggestion to go server-side on this is based largely on the fact that (at least by indication in our logs) a significant number of people still shut JavaScript off in their browsers.

    If this is a reasonably important function for you, taking it over to a Perl or PHP script server-side circumvents the possibility of failure in those cases where JavaScript is disabled by the visitor.


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
  •