/    Sign up×
Community /Pin to ProfileBookmark

$_POST not working in different directory

Good Morning All:

I built a small form that works as expected when the action URL is in the same directory as the form URL. When I move the action URL to a subdirectory, the form still can submit to the action URL, but the fields are not “posted.”

Any ideas?

to post a comment
PHP

14 Comments(s)

Copy linkTweet thisAlerts:
@donatelloApr 11.2010 — Did you change the form to be method="get" instead of method="post"?

Try using an absolute URL for the form. Wordpress forms can produce unexpected results that way...

Try posting your code, it makes our guessing easier! ?
Copy linkTweet thisAlerts:
@anwokoauthorApr 11.2010 — Thanks for your reply donatello. The form does submit fields with GET, but as you can see from the code, I think I should use POST because it is relatively sensitive information.

<form name='loginform' id='loginform' method='GET' action='http://www.prdrsvcs.com/ssl/indiv_login.php'>

<label>Username:</label><input type='text' name='username' /><br>

<label>Password:</label><input type='password' name='userpass' /><br>

<INPUT TYPE='image' name'submit' SRC='css/loginbutton1.gif' HEIGHT='26' WIDTH='60' BORDER='0' ALT='Submit Form' />

</form>
Copy linkTweet thisAlerts:
@EinsteinsEyesApr 11.2010 — Do you see the values of the fields in the get string when you use get action?
Copy linkTweet thisAlerts:
@anwokoauthorApr 11.2010 — I do see the values. It works fine with GET, but not with POST.
Copy linkTweet thisAlerts:
@Jarrod1937Apr 12.2010 — Can you add:

print_r($_POST);

To the beginning of your processing page and change the form to post. This will print out the $_POST superglobal array, see if your variables are printed out when you submit the form.
Copy linkTweet thisAlerts:
@anwokoauthorApr 12.2010 — Jarrod1937, thanks for your suggestion. I tried it, but nothing printed.

Before posting the thread, I had added the following line as a test:

echo "username post: ".$_POST['username']."</br>";

it only shows a value when I use GET
Copy linkTweet thisAlerts:
@Jarrod1937Apr 12.2010 — Jarrod1937, thanks for your suggestion. I tried it, but nothing printed.

Before posting the thread, I had added the following line as a test:

echo "username post: ".$_POST['username']."</br>";

it only shows a value when I use GET[/QUOTE]

I'm assuming you're changing it to $_GET['username'] when your form is using get to see the value?

Can we see your action page's code?
Copy linkTweet thisAlerts:
@EinsteinsEyesApr 12.2010 — Can you post the page you are using to process the form.
Copy linkTweet thisAlerts:
@anwokoauthorApr 12.2010 — This is what I have currently:


print_r($_POST);


echo "username post: ".$_POST['username']."</br>";

echo "username get: ".$_
GET['username']."</br>";

echo "uname: ".sql_replace($_POST['username'])."</br>";

/*

$username = sql_replace($_POST['username']);

$userpass = sql_replace($_
POST['userpass']);

*
/

$username = sql_replace($_GET['username']);

$userpass = sql_replace($_
GET['userpass']);
Copy linkTweet thisAlerts:
@EinsteinsEyesApr 12.2010 — Try _REQUEST instead of post. Does that fair any better. It should work with both post and get method.
Copy linkTweet thisAlerts:
@anwokoauthorApr 12.2010 — I just tried _REQUEST. Still nothing.

The only time I've seen this problem was when I tried using SESSION variables between directories. I would set the SESSION variable in one directory and it woouldn't exist in the next. I found something that talked about passing a sessionID as a GET variable in the address line and solved the problem that way.

Now I have the problem of not being able to use POST from directory to directory
Copy linkTweet thisAlerts:
@EinsteinsEyesApr 12.2010 — Sounds more like a security setting. I believe it is possible that the settings are such that post simply will not work. I think that would be very unusual. If the file is a php file. PHP scripting should be possible. Does the php work in the directory normally? Is the original form and processing directory a cgi-bin or something directory designated to run scripts?
Copy linkTweet thisAlerts:
@anwokoauthorApr 12.2010 — Whoaa! A little over my head there. The php in the directory does work normally...I think. I'm using a hosted server, so I didn't really do set-ups on that level. It gives me something to research though, so thanks.
Copy linkTweet thisAlerts:
@EinsteinsEyesApr 12.2010 — Unfortunately you might have to create a support ticket and show them your issue. I am sure they just set it up that way by default to protect the servers. At least I hope that is the reason. Best of Luck.
×

Success!

Help @anwoko spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...