Connecting Tech Pros Worldwide Help | Site Map

Trying to set form action to same page, but getting a 'not found' error.

Newbie
 
Join Date: Aug 2007
Location: Alesund, Norway
Posts: 26
#1: Aug 29 '07
Hi guys! Thanks a lot for helping me yesterday. But now I have a new problem. I have a module in joomla which I write PHP code in.
[PHP]$thisfile ="http://192.168.1.38/demotest/index.php?option=com_content&task=view&" . "id=" . "$id" . "&Itemid=" . "$itemid";[/PHP]

$id and $itemid are variables that tells me what to call on (the page I am on). the address I get when I print out is "http://192.168.1.38/demotest/index.php?option=com_content&task=view&id=12&Itemi d=26"
which is the current address I am on.


$thisfile is supposed to work in my form like this:
[PHP]<form id="form1" name="frmname" method="post" action="<? echo $_SERVER['$thisfile']?>">[/PHP]

But when I fill something in my form, and press submit, I get the following error: "The requested URL was not found on this server. The link on the ">referring page seems to be wrong or outdated. Please inform the author of ">that page about the error. If you entered the URL manually please check your spelling and try again."

I have tried to change the code, change the $thisfile, but I can't seem to fix it. It worked before :-(

What I want to do is call on itself, so I can fill out the form, submit it, and reload it.

Can anyone see anything wrong?


Phopman
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Aug 29 '07

re: Trying to set form action to same page, but getting a 'not found' error.


Changed thread title to better describe the problem (did you know that threads whose titles that do not follow the Posting Guidelines actually get FEWER responses?).
Newbie
 
Join Date: Aug 2007
Location: Alesund, Norway
Posts: 26
#3: Aug 29 '07

re: Trying to set form action to same page, but getting a 'not found' error.


Sorry about my bad title description. My english is lacking sometimes...
rpnew's Avatar
Familiar Sight
 
Join Date: Aug 2007
Posts: 180
#4: Aug 31 '07

re: Trying to set form action to same page, but getting a 'not found' error.


hi.. i'm not sure but try this..
[PHP]
$thisfile ="index.php?option=com_content&task=view&" . "id=" . "$id" . "&Itemid=" . "$itemid";
[/PHP]

instead of...

[PHP]
$thisfile ="http://192.168.1.38/demotest/index.php?option=com_content&task=view&" . "id=" . "$id" . "&Itemid=" . "$itemid";
[/PHP]

if you are accessing the page from the same directory then you dont need to provide whole path to the file......
Newbie
 
Join Date: Aug 2007
Location: Alesund, Norway
Posts: 26
#5: Sep 3 '07

re: Trying to set form action to same page, but getting a 'not found' error.


Thanks rpnew for the tip. I found out that if I had action ="" the script worked. Somehow...
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#6: Sep 3 '07

re: Trying to set form action to same page, but getting a 'not found' error.


Heya, Phopman.

Did you set a base href for the page? That might have thrown things off a bit.

For example, if your script were located at /forms/update.php, but your base href were http://yoursite.tld/, then you would run into problems:
Expand|Select|Wrap|Line Numbers
  1. <form action="update.php">
  2.  
Would attempt to post to /update.php, not /forms/update.php.

However,
Expand|Select|Wrap|Line Numbers
  1. <form action="">
  2.  
Posts to the same page... I think. I don't think it's part of a standard, but all browsers seem to implement it that way. But I don't like to trust it, which is why I usually use the basename(__FILE__) trick (though that won't work, as you can see, with a base href).
Newbie
 
Join Date: Aug 2007
Location: Alesund, Norway
Posts: 26
#7: Sep 4 '07

re: Trying to set form action to same page, but getting a 'not found' error.


No, I did not set a Base Href, only "".

Man, sometimes I just hate PHP. But I love it too. Mastering it a little by little give me satisfaction...
Reply