Hey, I have a submit button on the index page of my contact module, so the user can submit information by sending an email. I want the page to be self processing and call itself from the index file of the module, so I have code saying if the server request method is a post, then send the email.
Code:
if($_SERVER['REQUEST_METHOD'] == 'POST')
However when I try to call the page itself, I get a message saying "You can't access this file directly...". I saw this in the top of the module, but when I commented it out I got an error linking back to mainfile.php. Where should I define the MODULE_FILE, and what should I define it as?
Also I am adding AJAX to the module and for the page to look nice I need to make the body start look like
I tried calling it that way but I got an error saying:
Sorry, that module file was not found.
Also if I want to import a css style using @import, can I put it in the theme file style.css like:
@import "http://o.aolcdn.com/dojo/1.0/dijit/themes/tundra/tundra.css";
Joined: Aug 30, 2005 Posts: 2086 Location: near Albany NY
Posted:
Thu May 29, 2008 5:57 pm
Check the spelling, including spaces and capitalization of MODULENAME carefully. The statement that Evaders gave you is used throughout RN so it should work but you need to make sure that you have it exactly.
Also I think you want to use the format:
form method="post" name="member" action="modules.php?name=Purchase&file=new_member_info"
for example. My modulename is "Purchase" in that example and I put in & instead of just &.
As to the import, try it and see what happens. However, if you use multiple themes on your site you may need to modify the style.css for all of them.
I have found (for me any way) in utilising additional CSS styles is to either have the styles in the theme style.css, provided they do not conflict with a previously declared style or use an IF test in the custom header file to determine if your module is active $module_name then us the IF test to include a 'relative' style sheet which will then only be active when you are in that module.
If you need code for that I can post some.
Hmm..I tried changing the file, but didn't get much success. I still get the "Sorry, that module file was not found." message. Here is my code for the index page, hope this helps:
<?php
/*********************************************************
* Contact Module
* Andy Daykin 2008
* Module for users to contact the admin
********************************************************/
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* Based on Journey Links Hack */
/* Copyright (c) 2000 by James Knickelbein */
/* Journey Milwaukee (http://www.journeymilwaukee.com) */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* */
/************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/************************************************************************/
if (!defined('MODULE_FILE')) die('You can\'t access this file directly...');
if (isset($min)) $min = intval($min);
if (isset($show)) $show = intval($show);
require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$pagetitle = '- '._CONTACT;
define('INDEX_FILE', true);
if (!(isset($d_op))) $d_op = '';
if (!(isset($min))) $min = 0;
if (!(isset($orderby))) $orderby = '';
if (!(isset($show))) $show = '';
switch($d_op) {
default:
index();
break;
case 'AddDownload':
AddDownload();
break;
}
die();
function index() {
global $prefix, $db, $show_links_num, $module_name;
include_once('header.php');
OpenTable();
/*****************************************************
* Start the content section to be displayed specifc
* for this module
* **************************************************/
echo'
<br />
<p style="text-align: center;">
Please fill out the form below to receive a free quote. Fill out the form with as much detail as possible
so I can provide you with an accurate estimate. I will contact you by phone or email within 1-2 business days.
BTW Module name is '.$module_name .'
</p>
<br />
<br />
<form action="modules.php?name='.$module_name.' name="member" method="post">
<table align="center" summary = "Contact Info1" width= "70%" cellspacing = "2" cellpadding="5">
<tr>
<td bgcolor = "#A7DFC4" width="20%">
*Services
</td>
<td bgcolor = "#008000" width = "15%" align = "center">
<select name="services"
dojoType="dijit.form.ComboBox"
autocomplete="false"
<option value="Web Design" selected="selected">Web Design</option>
<option value="Web Programming">Web Programming</option>
<option value="Web Graphics">Web Graphics</option>
<option value="Page Layout">Page Layout</option>
<option value="Other">Other</option>
</select>
</td>
</tr>
<tr>
<td bgcolor = "#A7DFC4" width = "20%">
How many pages do you need?
</td>
<td Style = "color: white;" bgcolor = "#008000" width = "15%" align = "center">
<p>
<label for="pages1">1 - 8</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages1" value="1-8" checked="checked"/>
<label for="pages2">8 - 20</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages2" value="8-20" />
</p>
<p>
<label for="pages3">20 - 40</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages3" value="20-40" />
<label for="pages4">40+</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages4" value="40+" />
</p>
</td>
</tr>
<tr>
<td bgcolor = "#A7DFC4" width = "20%">
Do you plan to update the content yourself?
</td>
<td Style="color: white;" bgcolor="#008000" width="15%" align="center">
<label for="updates1">Yes</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates1" value="Yes" checked="checked" />
<label for="updates2">No</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates2" value="No" />
<label for="updates3">Not Sure</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates3" value="Not Sure" />
</td>
</tr>
<tr>
<td bgcolor="#A7DFC4" width="25%">
*Your Name
</td>
<td bgcolor="#008000" width="15%" align="center">
<input dojoType="dijit.form.TextBox" name="name" maxlength="35"/>
</td>
</tr>
<tr>
<td bgcolor="#A7DFC4" width="25%">
Location
</td>
<td bgcolor="#008000" width="15%" align="center">
<input dojoType="dijit.form.TextBox" name="location" maxlength="35"/>
</td>
</tr>
<tr>
<td bgcolor = "#A7DFC4" width = "25%">
Phone
</td>
<td bgcolor = "#008000" width = "15%" align = "center">
<input dojoType="dijit.form.TextBox" name = "phone" />
</td>
</tr>
<tr>
<td bgcolor = "#A7DFC4" width = "25%">
*Email
</td>
<td bgcolor="#008000" width="15%" align="center">
<input dojoType="dijit.form.TextBox" name="email" />
</td>
</tr>
<tr>
<td bgcolor = "#A7DFC4" width="25%">
Additional Comments
</td>
<td bgcolor = "#008000" width="15%" align="center">
<textarea dojoType="dijit.form.Textarea" name="comments" style="width:300px" style="height:300px">
</textarea>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><button type="submit" dojoType="dijit.form.Button">Submit</button></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>* Denotes required field</td>
</tr>
</table>
</form>
';
CloseTable();
include_once('footer.php');
}
// Determine whether the services selections were valid or not
// Generating the menu, then validate it
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
global $prefix, $db, $show_links_num, $module_name;
include_once('header.php');
OpenTable();
$choices = array('Web Design', 'Web Programming', 'Web Graphics', 'Page Layouts', 'Other');
if(! in_array($_POST['services'], $choices))
{
print "You must select a valid choice. \n";
}
// Determine whether the name was entered or not
// Set the name equal to the name form, then validate the name
$name = $_POST['name'];
if(! $name)
{
print "You must enter a name. \n";
}
// Check and see if email address is valid or not
if(! isValidEmailAddress($email))
{
print "Sorry, that email address is invalid. Please try again. \n";
}
// If everything is valid, send the email
if(isValidEmailAddress($email) && $name && in_array($_POST['services'], $choices))
{
// Send Email
print "We reached the email section";
$to = "daykinandy@gmail.com";
$subject = "Customer Inquiry";
$body = "Hello my name is $name \n" .
"My email is $email \n" .
"The services selected are " . $_POST['services']. "\n" .
"I need " . $_POST['pages'] . "\n" .
$_POST['update'] . " for updating the page" . "\n" .
"I am from " . $_POST['location'] . "\n" .
"My phone number is " . $_POST['phone'] . "\n" .
$_POST['comments'];
mail($to, $subject, $body);
}
CloseTable();
include_once('footer.php');
}
?>
Hey, thanks for the response. What I don't get is how do I define the different cases, i.e. how do I define it so that each case can get called? I changed my code so that the if($_SERVER['REQUEST_METHOD'] == 'POST') is now a function name, and tried defining it in the switch statement, however when I tried running the module I got the same message as before.
Code:
if (!defined('MODULE_FILE')) die('You can\'t access this file directly...');
if (isset($min)) $min = intval($min);
if (isset($show)) $show = intval($show);
require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$pagetitle = '- '._CONTACT;
define('INDEX_FILE', true);
if (!(isset($d_op))) $d_op = '';
if (!(isset($min))) $min = 0;
if (!(isset($orderby))) $orderby = '';
if (!(isset($show))) $show = '';
switch($d_op) {
default:
index();
break;
case 'checkMail':
checkMail();
break;
}
die();
function index() {
global $prefix, $db, $show_links_num, $module_name;
include_once('header.php');
OpenTable();
/*****************************************************
* Start the content section to be displayed specifc
* for this module
* **************************************************/
echo'
<br />
<p style="text-align: center;">
Please fill out the form below to receive a free quote. Fill out the form with as much detail as possible
so I can provide you with an accurate estimate. I will contact you by phone or email within 1-2 business days.
</p>
<br />
<br />
<form action="modules.php?name='.$module_name.'&d_op=checkMail" name="member" method="post">
<table align="center" summary = "Contact Info1" width= "70%" cellspacing = "2" cellpadding="5">
<tr>
<td bgcolor = "#A7DFC4" width="20%">
*Services
</td>
<td bgcolor = "#008000" width = "15%" align = "center">
<select name="services"
dojoType="dijit.form.ComboBox"
autocomplete="false"
<option value="Web Design" selected="selected">Web Design</option>
<option value="Web Programming">Web Programming</option>
<option value="Web Graphics">Web Graphics</option>
<option value="Page Layout">Page Layout</option>
<option value="Other">Other</option>
</select>
</td>
</tr>
<tr>
<td bgcolor = "#A7DFC4" width = "20%">
How many pages do you need?
</td>
<td Style = "color: white;" bgcolor = "#008000" width = "15%" align = "center">
<p>
<label for="pages1">1 - 8</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages1" value="1-8" checked="checked"/>
<label for="pages2">8 - 20</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages2" value="8-20" />
</p>
<p>
<label for="pages3">20 - 40</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages3" value="20-40" />
<label for="pages4">40+</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages4" value="40+" />
</p>
</td>
</tr>
<tr>
<td bgcolor = "#A7DFC4" width = "20%">
Do you plan to update the content yourself?
</td>
<td Style="color: white;" bgcolor="#008000" width="15%" align="center">
<label for="updates1">Yes</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates1" value="Yes" checked="checked" />
<label for="updates2">No</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates2" value="No" />
<label for="updates3">Not Sure</label>
<input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates3" value="Not Sure" />
</td>
</tr>
<tr>
<td bgcolor="#A7DFC4" width="25%">
*Your Name
</td>
<td bgcolor="#008000" width="15%" align="center">
<input dojoType="dijit.form.TextBox" name="name" maxlength="35"/>
</td>
</tr>
<tr>
<td bgcolor="#A7DFC4" width="25%">
Location
</td>
<td bgcolor="#008000" width="15%" align="center">
<input dojoType="dijit.form.TextBox" name="location" maxlength="35"/>
</td>
</tr>
<tr>
<td bgcolor = "#A7DFC4" width = "25%">
Phone
</td>
<td bgcolor = "#008000" width = "15%" align = "center">
<input dojoType="dijit.form.TextBox" name = "phone" />
</td>
</tr>
<tr>
<td bgcolor = "#A7DFC4" width = "25%">
*Email
</td>
<td bgcolor="#008000" width="15%" align="center">
<input dojoType="dijit.form.TextBox" name="email" />
</td>
</tr>
<tr>
<td bgcolor = "#A7DFC4" width="25%">
Additional Comments
</td>
<td bgcolor = "#008000" width="15%" align="center">
<textarea dojoType="dijit.form.Textarea" name="comments" style="width:300px" style="height:300px">
</textarea>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><button type="submit" dojoType="dijit.form.Button">Submit</button></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>* Denotes required field</td>
</tr>
</table>
</form>
';
CloseTable();
include_once('footer.php');
}
// Determine whether the services selections were valid or not
// Generating the menu, then validate it
function checkMail()
{
global $prefix, $db, $show_links_num, $module_name;
include_once('header.php');
OpenTable();
$choices = array('Web Design', 'Web Programming', 'Web Graphics', 'Page Layouts', 'Other');
if(! in_array($_POST['services'], $choices))
{
print "You must select a valid choice. \n";
}
// Determine whether the name was entered or not
// Set the name equal to the name form, then validate the name
$name = $_POST['name'];
if(! $name)
{
print "You must enter a name. \n";
}
// Check and see if email address is valid or not
if(! isValidEmailAddress($email))
{
print "Sorry, that email address is invalid. Please try again. \n";
}
// If everything is valid, send the email
if(isValidEmailAddress($email) && $name && in_array($_POST['services'], $choices))
{
// Send Email
print "We reached the email section";
$to = "daykinandy@gmail.com";
$subject = "Customer Inquiry";
$body = "Hello my name is $name \n" .
"My email is $email \n" .
"The services selected are " . $_POST['services']. "\n" .
"I need " . $_POST['pages'] . "\n" .
$_POST['update'] . " for updating the page" . "\n" .
"I am from " . $_POST['location'] . "\n" .
"My phone number is " . $_POST['phone'] . "\n" .
$_POST['comments'];
mail($to, $subject, $body);
}
CloseTable();
include_once('footer.php');
}
?>
Ok I added that line, I'm still getting the same error as before. Do I need to have it defined somewhere besides the lang-english files in my Contact directory?
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum