SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dynamic form action bath

    I have a form at a php file that will be include at several php scripts, so the action php script will change related to the folder of other php scripts.
    I am trying to pass the $rpath= '../' (relative path to the folder of the action script)
    but when I write <form action="<?php echo $rpath ?>/path/action.php" the $rpath is not writing.
    I try to write the dirname(__FILE__) (the action php is at the same file of form php) but there is also the url of the site (site/c://....)
    How can I solve this problem?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Post your code

  3. #3
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I mange to pass the path '/..' as the page that include the file is
    root/filepath
    and the form is
    root/modules/guest
    sto the form action is
    Code:
    action="/../modules/guest/guestbook.php"
    But now the error is The requested URL was not found on this server.
    What can I do?

  4. #4
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I also use this htaccess, also the absolute path (http://...) of the action script go to the index.php
    Code:
    Options +FollowSymLinks
    IndexIgnore */*
    RewriteEngine on
    #RewriteBase /
    
    #AuthName "Restricted Area" 
    #AuthType Basic 
    #AuthUserFile c:/xampp/htdocs/antenna/.htpasswd 
    #AuthGroupFile /dev/null 
    #require valid-user
    
    
    # if a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    
    # otherwise forward it to index.php
    
    #Rewriterule  ([^/]+)$  index\.php/$1 [L]
    RewriteRule ^(([^/]+)*)  index\.php/$1 [L] 
    #RewriteRule . index.php ^localpath(.*) otherpath$1 
    #RewriteRule ^.*$ /index.php [L]
    #RewriteRule . /index.php [L]
    #RewriteRule ^([a-zA-Z0-9]+)/$  /index.php [L]

  5. #5
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Use form action="/modules/guest/guestbook.php" instead of action="/../modules/guest/guestbook.php"

  6. #6
    SitePoint Member
    Join Date
    Jan 2009
    Location
    UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks so much for the tutorial. I followed it step by step.

  7. #7
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dimis283 View Post
    I have a form at a php file that will be include at several php scripts, so the action php script will change related to the folder of other php scripts.
    I am trying to pass the $rpath= '../' (relative path to the folder of the action script)
    but when I write <form action="<?php echo $rpath ?>/path/action.php" the $rpath is not writing.
    I try to write the dirname(__FILE__) (the action php is at the same file of form php) but there is also the url of the site (site/c://....)
    How can I solve this problem?
    Just want to share:
    Using relative paths creates problem most of the times.
    I simply use ABSOLUTE path by defining in some constant and has never get such issues of relativity problems.


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
  •