Forum Moderators: coopster

Message Too Old, No Replies

sessions problem

cant seem to pass form field

         

smad1

12:59 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



I have tried several different methods here, all to no avail, I am very new to php which i know is the main problem and would appreciate some direction.

i am trying to pass the name filled in on a form to a thanks.php page which is redirected after the form has been sent to FormMail.pl

Can i do this or do i need to post to a php page rather than the perl script first? is this my problem?

Thanks in advance for any help.

lorax

3:30 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not sure I follow the order of events. But in the case of form.html > FormMail.pl > thanks.php have you verified the variables from FormMail.pl are being passed to the thanks.php file?

smad1

4:02 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



No the formmail.pl is independent and sends the email etc. But i was hoping at the same time form.htm is filled and sent that i could grab a field. ie. client name and then use that on the thanks.php. There is no instruction from the formmail to pass the variable to the thanks.php. The thanks.php is an optional redirect field within the form.htm.

hope this clarifies what i am trying to do.

coopster

4:17 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm guessing you have something like:

<form method="post" action="formmail.pl">

and you want to run the thanks.php script after the formmail.pl script has run, correct?

lorax is suggesting you modify the formmail.pl script to run your php code when it is completed. Here is another thread similar to what is being described here [webmasterworld.com...]
but probably isn't going to help you out.

Otherwise, you could change your form POST action to run your PHP script instead and post that data to the formmail.pl script from your PHP code.

smad1

4:20 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



yes the thanks.php is run after the formmail has been executed..

If altering the formmail.pl is straight forward I will go that way..

The simpler the better :)

TIA

lorax

4:30 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So FormMail.pl gets the vars and does it's thing ok. Then it should either A) present a thank you page and you're done or B) pass the vars along to the thankyou.php page.

I'm not sure why you mention sessions. The vars you send to thankyou.php from the PERL script shouldn't pose a problem. How are you sending them along?

coopster

4:31 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



smad1, I don't use formmail but I believe you can set a hidden field in your form to do the redirect for you once the script has been processed. See this thread [webmasterworld.com...]
or better yet, the formmail documentation for more information on how to accomplish your task.

Regards -- coopster

smad1

4:46 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



lorax.
I am not sending them from the formmail I am or was trying to grab on from the form.htm part. the formmail script is a 3rd party script that i dont tend to open unless its changing the recipients and referers. I assummed i could take the $name as it was floating somewhere :)

<input type=hidden name="redirect" value="../thanks.php">
this is just a self made page that replaces the default thankyou text created.

<form action="cgi-bin/FormMail.pl" method="POST" name="enquire" id="enquire">
My form is actioned like this.

I have read alot of topics now and tbh am not that much the wiser. I mentioned sessions because i thought that on the form.htm i could save the entered name into a cookie or whatever needed.

am i missing something here or have u already told me what I need to do?

<input name="realname" type="text" id="realname" size="30" maxlength="60">
This is the field i want to display on the thanks.php

Maybe I am looking to hard into this.. sorry to be a nuisance :(

lorax

4:58 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ok, I'm with you now.

So the thankyou.php actually makes it to screen but doesn't output the vars you want it to or is it being called at all?

smad1

5:05 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



lorax.

the thanks.php makes it fine, just cant get the realname field to display.

lorax

5:24 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ok, the issue then is that you're working with two different scripts that aren't communicating. So what you need to do is to either add a thankyou to the FormMail.pl or somehow kluge a solution that will run the PERL script from within PHP. I've never had to deal with a situation like this but have you looked into the program execution functions [us4.php.net] within PHP?

Perhaps someone else might have a better direction to head in. Have you read through coopster's suggested thread?

smad1

5:28 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



yes i read coopsters thread and it hasnt helped :(

thanks for trying, much appreciated

coopster

5:29 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Basically, the form data is being POSTed to formmail.pl, including the "redirect" variable. However, the redirect subroutine of formmail does not POST data, it simply redirects to a new URL as a simple HTTP redirect, similar to the PHP header() function.
Snippet from formmail.pl:

# If redirect option is used, print the redirectional location header. #
if ($Config{'redirect'}) {
print "Location: $safeConfig{'redirect'}\n\n";
}

Therefore, no variable data is being passed to your php script. You would either have to modify the formmail.pl script or roll your own PHP script to handle the action.

coopster

5:54 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I have not tested this, but I think if you modified the print statement as follows...

print "Location: $safeConfig{'redirect'}?realname=$Form{'realname'}\n\n";

...it may work (as long as YOUR input name was actually "realname". Like I said, I haven't tested it...

smad1

6:39 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



i made the change u suggested coopster and the end of the URL is /thanks.php?realname=

this wasnt there before.

But.. using for example echo $realname still produces a blank. So i think i might need to get a php mailer.

smad1

6:41 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



oh and yes the field is called realname

coopster

6:48 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I looked at the current formmail code (Version: 1.92) at h**p://www.scriptarchive.com/formmail.html
so I may have the array information incorrect ($Form). Or I may be concatenating the URL together incorrectly. It probably just needs some minor tweaking. I noticed there is a FAQ issue listed on that site regarding the redirect:
3. The redirect command won't work.
There was a bug in older versions of this script and it has been fixed. Please download the latest version if you are using an old one.

smad1

6:51 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



I got it now thanks..

I changed $Form to $Config and it passed the realname in the URL.

Big thanks for all your help...really appreciated.