Forum Moderators: coopster

Message Too Old, No Replies

echo $_POST

         

vsmetc

10:35 pm on Apr 6, 2005 (gmt 0)

10+ Year Member



I have the following code in a program I am working on. I think I need a $_POST put in here someplace in order for a date to be posted. I'm not sure which part of this statement needs to be enclosed in the [ ] for the post.

<td width="5%">Sun<br> <?PHP echo "" . date ("n/j", mktime(0,0,0,$tmonth,$tday,$tyear));?></td>

I'm just getting started with this, so I'm sorry if this is too elementary.
Thanks for you help.

StupidScript

10:52 pm on Apr 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard, vsmetc!

The

$_POST[]
array contains elements resulting from a POST operation, like sending a form with
method=post
.

i.e.

PAGE1.PHP

<form action="PAGE2.PHP" method=post>

Name: <input name="user">

Pass: <input name="passwd">

</form>

PAGE2.PHP

<?

echo $_POST['user'];

?>

When the form on PAGE1 is submitted, its values are presented to PAGE2 in the

$_POST[]
array, which contains two items:
$_POST['user']
and
$_POST['passwd']
.

What's the problem with the script bit you posted? What are you expecting to see and what are you not seeing?

vsmetc

11:18 pm on Apr 6, 2005 (gmt 0)

10+ Year Member



Thanks for the reply. What I have is a web based timesheet where they enter a date and a form is displayed that has a work week and the dates of the week days displayed corresponding to that work week. We have recently changed servers and the timesheet is not working properly since then. Here is the URL of the one that works and also the URL of the one that isn't working.

[edited by: jatar_k at 11:59 pm (utc) on April 6, 2005]
[edit reason] sry no personal urls thanks [/edit]

jatar_k

12:02 am on Apr 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld vsmetc,

my wild guess is it sounds like you moved from an environment with register_globals ON to OFF

one thing that would start it working right away but that I do not suggest to leave in place is to use extract [php.net]

put this in the top of the pages that are being posted to

extract($_POST);

this will make them work for now while you get it sorted out.

StupidScript

12:09 am on Apr 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



(Beat me to it, jatar_k! I must learn to type faster!)

My guess is that on the old server you had your PHP set up to

register globals
, so you could simply refer to the form variables by name on the capture page, and use them to calculate
$tmonth
and the rest.

Without

register globals
turned on, you do need an alternate means of grabbing the form data.

Without seeing your actual code, here's my guess:

On cal2.php, you currently use

$date_from_form

$month_from_form
and
$year_from_form

You would need to change this (as jatar_k suggests, or)

$_POST['date_from_form']

$_POST['month_from_form']
and
$_POST['year_from_form']

in order to grab the POST variables without

register globals
being turned on.

vsmetc

11:27 pm on Apr 7, 2005 (gmt 0)

10+ Year Member



Thank you one and all. It works! It almost didn't because I used double quotes instead of single quotes. But when I changed those it popped up right away. I appreciate everyone who jumped right in with suggestions.