Author |
Message |
CodyG
Life Cycles Becoming CPU Cycles

Joined: Jan 02, 2003
Posts: 714
Location: Vancouver Island
|
Posted:
Fri Jun 11, 2004 9:34 am |
|
Newbie, wanna be, probably never will be programmer here....
I'm developing a new form module.
I've been playing around with this for a day now... thought I'd come for some guru help because I'm at a loss as to what to try next.
It's a help/bugreport/question form which sends an email with the form data. Everything is groovy, the form (form2mail) is integrated, the mail get's sent, but the redirect to the thankyou... how do I get that integrated?
There are four files in the module:
index.php ... includes help.php
help.php .. the html form <form method=POST action=/modules/Help/helpdo.php>
helpdo.php .. the php that process the form and redirects
thankyou.php .. after the form is successfully submitted this page should be displayed and it is... I just need to integrate this page into nuke tables with headers etc.
But when I attempt to do that I get errors... cannot access this file directly, so I removed the if statement. Then the error is can't find mainfile.php, but after removing that, I'm down to basic html and that doesn't work.
What am I missing here? How do I redirect to a thankyou and keep it inside nuke? |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Mon Jun 21, 2004 6:48 am |
|
I will assume that you know how to call the redirect itself. To keep it w/i nuke, you will need to call a module that has your Thank You note in it. Just make a standard module, possibly called modules/Thank_You/index.php. Then, in your redirect, you would code http://your_domain.com/modules.php?name=Thank_You . Does that help? |
|
|
|
 |
CodyG

|
Posted:
Mon Jun 21, 2004 8:11 am |
|
Why would I need to call the thankyou file from a different module? Why not just call thankyou.php from the same module?
$redirectURL = "http://mydomain.ca/modules.php?name=Help&file=thankyou"; // the URL of the thank you page.
But that doesn't work either, the page is still outside nuke.
So, I went to the Nuke manual and found this solution...
$redirectURL = "http://mydomain.ca/modules.php?name=Help&page=thankyou.php"; // the URL of the thank you page.
or this one
http://mydomain.ca/modules.php?name=Help&file=thankyou
But they don't work either, only the form page is displayed, not the thankyou page.
I've been trying to find some similiar redirect in some nuke module... no luck yet. Any more clues? |
|
|
|
 |
Raven

|
Posted:
Mon Jun 21, 2004 8:16 am |
|
|
|
 |
CodyG

|
Posted:
Mon Jun 21, 2004 8:36 am |
|
http://mydomain.ca/modules.php?name=Help&file=thankyou
That should work! so how come the thankyou isn't inside nuke?
$redirectURL = "http://mydomain/modules.php?name=Help&file=thankyou"; // the URL of the thank you page.
<snip helpdo script which sends the mail>
then this ...
header("Location: ".$redirectURL);
Is that what's causing this issue? |
|
|
|
 |
Raven

|
Posted:
Mon Jun 21, 2004 9:03 am |
|
Is thankyou built like index.php as a module? |
|
|
|
 |
CodyG

|
Posted:
Mon Jun 21, 2004 10:57 am |
|
no, raven, the thankyou.php is plain html. hmm... I already tried making the thankyou.php like a module, but got all kinds of errors looking for mainfile or disallowing access. |
|
|
|
 |
Raven

|
Posted:
Mon Jun 21, 2004 11:02 am |
|
Make it like a module. Also try NOT fully qualifying the redirect. Only use modules.php?name=Help&file=thankyou . Some setups don't allow you to use http://. I know this works as I have done it before. |
|
|
|
 |
CodyG

|
Posted:
Mon Jun 21, 2004 12:47 pm |
|
how hard can this be? Now I'm not getting mail from the form. I've made the thankyou.php like a module index file, but the script is no broken before sending that file.... perhaps it's my form action... ?? (which was working as long as I wasn't trying to put the thankyou page inside nuke.)
<form method=post action=modules.php?name=Help&file=helpdo>
or...
<form method=post action=modules.php?name=Help&file=helpdo.php>
or
<form method=post action=modules.php?name=Help&file=helpdo>
No matter what I try, I'm now getting a "sorry, page cannot be found" instead of the form processing and the thankyou page.
And the $redirectURL is now like this:
$redirectURL = "modules.php?name=Help&file=thankyou"; // the URL of the thank you page.
 |
|
|
|
 |
Raven

|
Posted:
Mon Jun 21, 2004 2:08 pm |
|
Okay, lets try another approach. I have written 2 scripts that should demonstrate the way I am understanding this issue and how to solve it. I am assuming that you have scriptA that allows the user to submit a report. You then want to have the report details emailed and then produce a Thank You page (scriptB). Here would be one way.
This script is the main module and I have named it -- Cody.
Code:<?php
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}
include("header.php");
OpenTable();
?>
<form action="modules.php?name=Cody&file=sendandreply" method="POST">
Type message here: <input name="msg">
<br />
<br />
<input type="submit" name="submit" value="Submit">
</form>
<?
CloseTable();
include("footer.php");
?>
|
This is the script that Cody calls to email and display a Thank You screen.
Code:<?php
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}
include("header.php");
OpenTable();
if (empty($_POST['msg'])) {
header("location: modules.php?name=Cody");
die();
}
//mail();
?>
Thank you for your Report. We will get back to you soon!
<?
CloseTable();
include("footer.php");
?>
|
Now I have not included the email() function, but instead just made a place for it. Save both of these scripts to a folder called Cody. The fiorst one should be named index.php and the second sendandreply.pnp. Does this help or not? |
|
|
|
 |
CodyG

|
Posted:
Mon Jun 21, 2004 5:06 pm |
|
According to you Raven, I've got too many files ... it seems logical to me, and the script features, to separate all these things.
file 1. modules/Help/index.php // follows nuke modules rules for every index.php; includes help.php
file 2. modules/Help/help.php // This is the form, html only // form action=helpdo.php (path should be relative, right?)
file 3. modules/Help/helpdo.php // This is the function that takes the form data and mails it and redirects to thankyou.php (edited from code by George A. & Calin S. from Web4Future.com) html and php
Code:
$MailToAddress = "something@something.ca";
$redirectURL = "modules.php?name=Help&file=thankyou";
# optional settings
$MailSubject = "[Help, Question, Bug Report]";
$MailToCC = "something@something.ca";
$Message = "";
if (!is_array($HTTP_POST_VARS))
return;
reset($HTTP_POST_VARS);
while(list($key, $val) = each($HTTP_POST_VARS)) {
$GLOBALS[$key] = $val;
if (is_array($val)) {
$Message .= "<b>$key:</b> ";
foreach ($val as $vala) {
$vala =stripslashes($vala);
$Message .= "$vala, ";
}
$Message .= "<br>";
}
else {
$val = stripslashes($val);
if (($key == "Submit") || ($key == "submit")) { }
else { if ($val == "") { $Message .= "$key: - <br>"; }
else { $Message .= "<b>$key:</b> $val<br>"; }
}
}
} // end while
$Message = "<font face=verdana size=2>".$Message;
mail( $MailToAddress, $MailSubject, $Message, "Content-Type: text/html; charset=ISO-8859-1\r\nFrom: ".$email."\r\nBCc: ".$MailToCC);
header("Location: ".$redirectURL);
?>
|
file #4 modules/Help/thankyou.php // this is the thankyou file //html only
I like the above method, it seems tidy and reuseable. I just need to understand why it won't put the thankyou.php in nuke without sending errors and/or breaking the mailer.
Something about
header("Location: ".$redirectURL);
bugs me... You suggested I make thankyou.php comply with nuke module rules... but that would include a header() in the thankyou.php too. It would conflict with the above script, right?
I'll probably end up with your method, using 2 files, because I know that method works for sure as I use it on other forms. I just really liked this bit of mailing script so I'll want to find a way to make it do what I want to do in nuke, by a different method ... tomorrow.
Thanks Raven. |
|
|
|
 |
Raven

|
Posted:
Mon Jun 21, 2004 5:30 pm |
|
No, the headers are 2 different animals. |
|
|
|
 |
|