form processing within a module

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   form processing within a module
darkstonexa
CZ Newbie
darkstonexa has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Oct 20, 2003
0.00 posts per day
Posts: 13
Points: 1,194
   
I have found this php script that I am slowly converting in to a module,
everything has been running brilliantly till now.

I have sevreal forms in this script but I can't get any of them to work inside the module in phphnuke.

this is the line I am having major problems with

if (!eregi("modules.php", $PHP_SELF)) {
   die ("You can't access this file directly...");

}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
$index = 1;

?>
<form action=modules.php?name=auction&file=proc_reg method="post">

...rest of the form..........


I included the first bit so that the script will stay inside the nuke site as a block in the middle and that works fine.
but every time I try to submit the form I get file not found i.e it can't find proc_reg.php file.

now if I type the address straight into the address bar
as [ Register or login to view links on this board. ]

it finds the file fine but not via the submit button on the form.

Oh and something else that might give you guys a pointer to my troubles, everytime I load one of these form pages I get
"Sorry, such file doesn't exist..." at the bottom of the form

I Turned on error codes in php.ini and discovered it has a problem with line 227 in the mainfile.php of phpnuke.
which is in reference to some pwd password..

but anyway if someone can tell me why by hitting the submit button phpnuke turns round and says an't find the file I will be over the moon..
but 48 hrs solid of trying to get the form to work I am now lost as to a solution short of someone rewritng the forms in a different format, which I don't know how to do.


Back to top Reply with quote
#2   re: form processing within a module
Taut
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
Taut has been a member for over 20 year's 20 Year Member
usa.gif california.gif
Occupation: Entrepreneur
Gender: Female
Fav. Sports Team: SF Giants
Status: Offline
Joined: May 27, 2003
0.72 posts per day
Posts: 5530
Points: 481,695
   
echo"<form action=modules.php?name=auction&file=proc_reg method=\"post\"> "
."";




taut


Back to top Reply with quote
#3   re: form processing within a module
darkstonexa
CZ Newbie
darkstonexa has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Oct 20, 2003
0.00 posts per day
Posts: 13
Points: 1,194
   
Thanks but I tried that as well
and it still comes up with the error file doesn't exsist.

I even went to the point of converting all the html code so it resided inside the php tags.
but what ever I do it doesn't work.

if I load the page that has the form in it, and change the form action tag and insert the direct path in it to the file, then the form works.
but load it via the modules.php descriptor it doesn't work.

here is the latest version of the code all converted so it resides in php tags.
but still produces a file doesn't exsist when you hit submit on the button.


<?php
#### Generated by Module Creator - By Disipal site (www.disipal.net) ####
if (!eregi("modules.php", $PHP_SELF)) {
   die ("You can't access this file directly...");

}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
$index = 0;

OpenTable();
echo"<form action=modules.php?name=auction&file=proc_reg method=\"post\"> "
  . "<center><H2>New User Registration</H2></center>"
  . "<center><TABLE WIDTH=668 BORDER=1 CELLPADDING = 5 BGCOLOR=#EEEEEE></center>"
  . "<TR><TD COLSPAN=2 VALIGN=TOP width=\"650\">"
  . "    <p align=\"left\"><b>This form will allow you to register to buy auction"
  . "items.  You must enter accurate data, and your new password will be e-mailed"
  . "to you.  Please be patient after hitting the submit button.  Registration may take"
  . "a few seconds.<br>"
  . "    <br>"
  . "    Note: Items marked with a </b><font color=\"#FF0000\">* </font><font color=\"#000000\"><b>required"
  . "    fields.</b></font></p>"
  . "  </TD></TR>"
  . "<center>"
  . "<TR><TD VALIGN=TOP width=\"220\">Username:</TD><TD width=\"416\"><input type=\"text\" name=\"user\" size=\"40\">"
  . "    <font color=\"#FF0000\">*</font>"
  . "<TR><TD VALIGN=TOP width=\"220\">Full Name:</TD><TD width=\"416\"><input type=\"text\" name=\"name\" size=\"40\">"
  . "    <font color=\"#FF0000\">*</font>"
  . "<TR><TD VALIGN=TOP width=\"220\">Email Address:</TD><TD width=\"416\"><input type=\"text\" name=\"email\" size=\"40\">"
  . "    <font color=\"#FF0000\">*</font>"
  . "<TR><TD VALIGN=TOP width=\"220\">Address Line 1:</TD><TD width=\"416\"><input type=\"text\" name=\"add1\" size=\"40\">"
  . "    <font color=\"#FF0000\">*</font>"
  . "<TR><TD VALIGN=TOP width=\"220\">Address Line 2:</TD><TD width=\"416\">"
  . "<input type=\"text\" name=\"add2\" size=\"40\">"
  . ""
  . "</TD></TR>"
  . "<TR><TD VALIGN=TOP width=\"220\">City:</TD><TD width=\"416\">"
  . "<input type=\"text\" name=\"city\" size=\"40\"> <font color=\"#FF0000\">*</font>"
  . ""
  . "</TD></TR>"
  . "<TR><TD VALIGN=TOP width=\"220\">State:</TD><TD width=\"416\">"
  . "<input type=\"text\" name=\"state\" size=\"40\"> <font color=\"#FF0000\">*</font>"
  . ""
  . "</TD></TR>"
  . "<TR><TD VALIGN=TOP width=\"220\">Zip Code:</TD><TD width=\"416\">"
  . "<input type=\"text\" name=\"zip\" size=\"40\"> <font color=\"#FF0000\">*</font>"
  . ""
  . "</TD></TR>"
  . "<TR><TD VALIGN=TOP width=\"220\">Country:</TD><TD width=\"416\">"
  . "<input type=\"text\" name=\"country\" size=\"40\"> <font color=\"#FF0000\">*</font>"
  . ""
  . "</TD></TR>"
  . "<TR><TD VALIGN=TOP width=\"220\">Telephone Number:</TD><TD width=\"416\">"
  . "<input type=\"text\" name=\"phone\" size=\"40\"> <font color=\"#FF0000\">*</font>"
  . ""
  . "</TD></TR></TABLE></center><P>"
  . "<CENTER>By registering with "
  . "<?php"
  . "print \"<b>$site_name</b>\\n\";"
  . "?>"
  . " you will automatically be added to our mailing list.<br><INPUT TYPE=SUBMIT VALUE=\"Register\"></CENTER>"
  . "</form>"
  . "<?php"
  . "include 'footer.inc';";
CloseTable();
include("footer.php");

?>


okay slight update I was barking up the wrong tree I think. the problem is in the file I am trying to access that processes the form.

I ran some values through the form and form only works properly using certain values such inserting test or my name "james" in every field.

if I use other values then I get a file not found error when I hit submit on the form button.

I know it might be a bit much but could somone look at this code as well which is the file that processes the form values, just in case their is something in their that won't work with phpnuke.

<?php
#### Generated by Module Creator - By Disipal site (www.disipal.net) ####
if (!eregi("modules.php", $PHP_SELF)) {
   die ("You can't access this file directly...");

}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
$index = 0;


include 'settings.php';
include 'header.inc';

OpenTable();

// Do some error checking

// Here we check to make sure the username is not already taken
$linkID2 = @mysql_connect("$server", "$username", "$password");
mysql_select_db("$database", $linkID2);
$resultID2 = mysql_query("SELECT user, email FROM registration", $linkID2);
for ($x= 0; $x < mysql_num_rows($resultID2); $x++) {
   $row = mysql_fetch_assoc($resultID2);
   if ($user == $row[user]) {
      print "<br><br><center><font color=green><b>Sorry, the username </font><font color=red>$user</font><font color=green> is already taken.<br>Click back and select a different username.</b></font><br><br></center>\n";
      include 'footer.inc';
      die;
   }
   if ($email == $row[email]) {
      print "<br><br><center><font color=green><b>Sorry, the email address </font><font color=red>$email</font><font color=green> is already taken.<br>Click back and select a different email address.</b></font><br><br></center>\n";
      include 'footer.inc';
      die;
   }

}


// Check to make sure all required fields has something in them or kick back an error.
if (($email == "") or ($add1 == "") or ($city == "") or ($zip == "") or ($country == "") or $phone == "") {
   print "<br><br><center><font color=green><b>All fields marked with an * are required.<br>Click back to try again.<br><br></center></font></b>\n";
   include 'footer.inc';
   die;
}

// Make random password here
// TBD

srand((double)microtime()*1000000);
$ID = substr(md5(rand(0,32000)), 0, 10);
$r = rand(0,1);
if ($r == "0") {
   $ID;
} else {
   $ID = strtoupper($ID);
}
$pass = $ID;



// Add a record
$linkID = @mysql_connect("$server", "$username", "$password");
mysql_select_db("$database", $linkID);

$result = mysql_query("INSERT INTO registration (user, email, pass, name, add1, add2, city, state, zip, country, phone, active,
sell) VALUES ('$user', '$email', '$pass', '$name', '$add1', '$add2', '$city', '$state', '$zip', '$country', '$phone', '$active', '$sell')", $linkID);

mysql_close($linkID);

// Make sure the record was added to the SQL database
if ($result == TRUE) {
   print "<center>User record was successfully added to the database.<br><br></center>\n";
} else {
   print "<center><font color=red><b>The server was unable to write to the MySQL DataBase.</b></font></center>\n";
}

//include "welcomeuser.email.inc.php";

//$email_send = strip_tags($email);
//$sendto = "$email";
//$subject = "Welcome to $site_name";
//mail($sendto, $subject, $msg, $headers);

CloseTable();
include("footer.php");

?>

These two files work fine if you run them outside phpnuke.


Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
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
You cannot attach files in this forum
You cannot download files in this forum