SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HTML form action=URL with index(.)aspx

    I have a HTML form that truncates the action URL parameter after the question mark symbol - which is NOT the desired behavior I am looking for. I simply want to open the referenced URL within the same viewport.

    I cannot provide the HTML snippet - getting a forum error message 'cuz I'm a new forum user....

    In this case, the submit button takes you to the index(.)aspx page, effectively ignoring the parameters after the question mark. It appears that URL's using HTML and PHP pages referenced in the a work as expected BUT (alas) this is not the case when the target page contains index(.)aspx. Cut and paste of the full URL into the toolbar brings me to the correct webpage. This behavior is consistent across all major browsers (IE, FF, Safari, Chrome, Opera).

    Has anyone seen this problem before? Or can suggest an alternative and/or workaround consistent with my "pure" CSS/HTML/PHP web development approach? I have tried replacing the special characters with HTML entity values with no impact. I REALLY don't want to use abandon my CSS-styled submit buttons by using Javascript or button PNG's or image maps.

    Environment:
    Web Server: Apache 2.2.14
    PHP: 5.2.10
    OS: Mac OS X 10.5.8

    TIA --

  2. #2
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <form action="www.spufalcons.com/index(.)aspx?tab=gymnastics&path=gym">
    <input type="submit" value="Gymnastics"/>
    </form>

  3. #3
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PLZ Substitute a "." for the "(.)" in the previous post....
    Being a newbie is a pain in the neck....

  4. #4
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
        <form action="www.spufalcons.com/index[DOT]aspx?tab=gymnastics&path=gym">  
        <input type="submit" value="Gymnastics"/>
        </form>

  5. #5
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as i understand you want to pass values from one page to another. But i dont think the way you are doing it is a right way.

    There are two methods to pass vale from one page to another.

    1) Using sessions
    2) pass value with urls

    Using session is the best method to pass value from one page to another, i ll show you small example here

    Try this-
    page1.php
    PHP Code:
     <?php
       
    // this starts the session
       
    session_start();

       
    // this sets variables in the session
       
    $_SESSION['tab']="gymnastics";
       
    $_SESSION['path']="gym";


    ?>
        <form action="page2.php" method="post">
        <input type="submit" name= "submit" value="submit"/>
    page2.php

    PHP Code:
    <?php
    // this starts the session
    session_start();

    // echo variable from the session, we set this on our other page
    echo "your first value is ".$_SESSION['tab'];
    echo 
    "your second value is ".$_SESSION['path'];
    ?>

  6. #6
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All I'm trying to do is open an external webpage from my page. For example, if my webpage is www.example.com, I want the submit button from this page to go the the external webpage http://www.spufalcons.com/index.aspx...stics&path=gym.

    The problem I'm having is that the HTML form is truncating the URL (deleting everything AFTER the ?tab=gymnastics&path=gym) and therefore presenting only www.spufalcons.com/index.aspx - which is not the target destination....

    Use of PHP session variables seems like overkill - I shouldn't think I would have to break out the URL parameters and then recompose the URL string on a new page (or via AJAX) to simply to display a new URL within my active viewport. The Javascript command OnSubmit will work but I don't want my buttons to be dependent on Javascript to work....

    Somehow the URL defined by my HTML <form action=URL> is being truncated either en route to the ASP host or by the ASP host. URL's ending in .html or .php or even .com/ work as expected....

  7. #7
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I understand your problem now. but when i checked your following url i didn't find anything there. please check this url properly first whether its working or not


  8. #8
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The default submit method for a form is GET. An HTTP GET request passes the field values as URI parameters, obliterating any parameters in your action URI.

    You have two choices: use a POST action instead or include the 'fixed' parameters as hidden fields in the form.

    Solution #1,
    Code HTML4Strict:
    <form action="www.spufalcons.com/index.aspx?tab=gymnastics&path=gym" method="post">  
      <div>
        <input type="submit" value="Gymnastics">
      </div>
    </form>

    Solution #2,
    Code HTML4Strict:
    <form action="www.spufalcons.com/index.aspx">
      <div>
        <input type="hidden" name="tab" value="gymnastics">
        <input type="hidden" name="path" value="gym">
        <input type="submit" value="Gymnastics">
      </div>
    </form>

    Note that using a POST action may make it necessary to modify your server-side script. (I don't know .NET)
    Birnam wood is come to Dunsinane

  9. #9
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solution #1 is an ideal approach. Thank YOU!

    Solution #2 with hidden fields would require a reasonably complex parsing algorithm to handle the complexities of the URL parameter variants maintained in a sizeable database.

  10. #10
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solution #1 seems to be is an ideal solution to this problem. I have no control over the external "target" URL's nor their server-side scripting.

    I do have a follow-up question. In looking at my MySQL database of URL's it appears that ~30&#37; of the URL's will need to use this post/div wrapper approach. This leaves ~70% that cannot accept the "post" attribute. For example:

    Code:
      <form action="http://www.google.com" method="post">
        <div>
    	<input type="submit" value="Google"/>
        </div>	
      </form>
    does not work. Do you have a recommendation for how to best handle this get/post condition test. Off the top of my head I'm guessing that using PHP to evaluate the existence of the "?" character in the URL may be my best approach, although I'm not sure how to structure the HTML form to accomplish this.

    In my case, Solution #2 using hidden input fields is not optimal. It would require a reasonably complex parsing algorithm to handle the complexities of all URL parameter variants maintained in a sizeable MySQL database.

    Thank YOU!

  11. #11
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The absence of a '?' character in the URI does not imply that the target accepts or understands POST requests, so you can't use that to determine the method. There is no reliable way of knowing, from the URI, which request methods a particular script or application accepts. You'll just have to find out and store this information in your database along with the URIs themselves.

    Parsing query parameters shouldn't be too difficult, as long as they use an '&' character as the parameter separator and a '=' character between the parameter name and the associated value. This is a convention that most (but not all) sites adhere to.
    Birnam wood is come to Dunsinane

  12. #12
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was able to apply CSS styling to an anchored HREF attribute fully emulating the push button behaviors I needed (hover, active, background-color, etc., etc.). HTML markup is much simpler a-n-d eliminates the get/post complexity associated with using a form-based approach.
    Code:
    <a class="GYM" href="http://www.spufalcons.com/index.aspx?tab=gymnastics&path=gym">Gymnastics</a>


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
  •