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

Thread: Forms

  1. #1
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Forms

    Hey, i have multiple forms on each page (most pages) of a cms, yet when i click on a submit button for one, the other one submits blank data.
    i don't want my visitors to keep seeing errors about having a blank message if they're using the shoutbox for example.

    I've tried giving the forms different names, this still doesn't fix the problem.
    Any Advice?

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Use a different method for each form, eg for one method="submit.php?type=1" and then in submit check only if the type is in the URL

  • #3
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    wtf, thats a dumb way, all my forms are submitted via POST (more secure) and each form is on a different script.
    but i include them so hence one page, lots of forms. and i'm not using GET Url's

  • #4
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    I meant action in my last post instead of method.

    Alternatively you could use a hidden input field with the type instead of using GET

  • #5
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    but still thats scruffy.. i want it to be smart and neat.

  • #6
    Regular Coder anarchy3200's Avatar
    Join Date
    Mar 2003
    Location
    England
    Posts
    261
    Thanks
    0
    Thanked 1 Time in 1 Post
    POST being a more secure method may be a slight stretch of the imagination but i'll go with it.

    It is possible to set the method as post but then set the action to include the get variable
    i.e. <form action="page.php?go=1" method="post">
    then you still access your form data using post but check if go=1 to execute the relavent actions.
    For your multiple forms your could either set different variables i.e. go=1, back=1 or you could have one variable with different values i.e. go=1, go=2

    This is the most common way of doing this.
    Mike

  • #7
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    thanks mike, but i don't want to use a get action as it looks scruffy as hell. any other ideas?

  • #8
    Regular Coder anarchy3200's Avatar
    Join Date
    Mar 2003
    Location
    England
    Posts
    261
    Thanks
    0
    Thanked 1 Time in 1 Post
    Well i don't agree with your reasoning but next method:

    Just make sure all your form fields have different names then for your processing enter the block with the usual if(isset$_POST['xyz'])){
    then inside that just check what fields are set.
    i.e. 2 forms, one with username and password, one with name and date.
    if username and password are set
    execute this
    elseif name and date are set
    execute this
    Mike

  • #9
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    lolz, don't worry i got another idea.


  •  

    Posting Permissions

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