Include script won't process form
Posted: Mon May 10, 2010 5:28 pm
10 May 2010 3:13 PM
I am working on an accounts program in which I want to set up a new account. I can't make it work the way I want. The form contained in the 'include' file will not process.
Please help.
Thanks in advance
Rick P
=================================================================================================================================
Structure is briefly as follows:
A. ShowCompany.php Shows company information to be processed or opportunity to create a new account.
In which has: Form in which: action='ProcessAccountData.php'
submit choices are: All 4 choices name='operation' 1. No Change/Exit 2. Revise This Account 3. New Account 4. Delete This Account
B. ProcessAccountData.php ........... I use switch to process $_POST from ShowCompany.php.
switch ($_POST['operation']) {
.
.
.
===>> case "New Account":
include "NewAccount.php"; // returns here without ever having stopped to receive submits see code below
code here to create $query and input to MySql
break;
default:
exit("Bye Bye From switch");
break;
}
C. NewAccount.php Full code below: If I un-comment the "require files" and run this as a stand alone script it works fine.
If I try to call it from the switch in ProcessAccountData.php ("require" files can't be used or you
get errors) as below, the code returns to the switch statement without processing the submit code.
=======================================================================================================================
NewAccount.php Code
I am working on an accounts program in which I want to set up a new account. I can't make it work the way I want. The form contained in the 'include' file will not process.
Please help.
Thanks in advance
Rick P
=================================================================================================================================
Structure is briefly as follows:
A. ShowCompany.php Shows company information to be processed or opportunity to create a new account.
In which has: Form in which: action='ProcessAccountData.php'
submit choices are: All 4 choices name='operation' 1. No Change/Exit 2. Revise This Account 3. New Account 4. Delete This Account
B. ProcessAccountData.php ........... I use switch to process $_POST from ShowCompany.php.
switch ($_POST['operation']) {
.
.
.
===>> case "New Account":
include "NewAccount.php"; // returns here without ever having stopped to receive submits see code below
code here to create $query and input to MySql
break;
default:
exit("Bye Bye From switch");
break;
}
C. NewAccount.php Full code below: If I un-comment the "require files" and run this as a stand alone script it works fine.
If I try to call it from the switch in ProcessAccountData.php ("require" files can't be used or you
get errors) as below, the code returns to the switch statement without processing the submit code.
=======================================================================================================================
NewAccount.php Code
Code: Select all
<html>
<head><title>Account Companies</title></head>
<body>
<?php
// require "db-accts.inc"; When using as stand alone script must un-comment
// require "functions.inc"; these to avoid duplicate declaration errors.
//require "functions-accounts.inc";
if(!isset($pass)) { // avoiding errors when $_SERVER[PHP_SELF] runs itself again
$cxn = mysqli_connect($hostname,$username,$password,$database)
or die ("couldn't connect to server");
$labels=array_combine(getTableFields($cxn, $table), $colhead); // getTableFields in functions.inc
listArray($labels); // listArray in functions-accounts.inc
}
$pass='yes';
echo "<form action='$_SERVER[PHP_SELF]' method='POST'>
<table>";
foreach($labels as $field=>$label) {
if($field=="Hints") // create 'text area' rather than text line
echo "<tr><td style='text-align: left;
font-weight: bold'>$label</td>
<td><textarea name='$field'
rows='4' cols='65' wrap='wrap'> $row[$field]
</textarea>
</td></tr> ";
else
if($field=="IDno") continue; // IDno must be void in new account so don't show it
else
echo "<tr>
<td style='text-align: left;
font-weight: bold'>$label</td>
<td><input type='text' name='$field'
value='$row[$field]' size='65'
maxlength='65'>
</td></tr> ";
}
echo "<tr><td> </td>
<td style='text-align: left'>
<input type='submit' name='go' value='Never Mind, Abort'>";
echo "   <input type='submit' name='go' value='Store New Account'>";
echo "</td></tr></table>
</div>
</form>";
$action=$_POST['go'];
$StoredArray=($_POST); // these two lines to be used to generate $query and pass to MySql
/*
sleep(5);
echo "GO<br>", $_POST['go'], "<br>"; debugging stuff
listArray($_POST);
echo "Stored Array <br>";
$StoredArray=($_POST);
listArray($StoredArray);
exit("Bye from Newaccount");
*/
?>
</body></html>