0

I need to pass close to 100 variables between pages and I'm not sure of the best way to do it. Any suggestions?

5
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by jstfsklh211
0

or you could have a database that has all your variable names and then the values asigned to each variable. you could then select each variable as you need it and be able to update / delete etc whenever you like.

can you give an example of what youve written, or what purpose it has, it may be easier for others to give you ideas

0

The company I work for has a customer database using MS Access with a vb6 gui/form for looking up & editing the information about each customer. There are many many input fields on the existing application and I'm working on converting this to php/mysql. Maybe I'm going at this the wrong way - at the bottom of the existing vb6 form there are several buttons that do things such as save changes, create new record, delete existing record, or go back to the search screen. What I had come up with in php to replicate this was to have the buttons, each one as type "submit", each one with the same name "submission", and sending those values to another php page which would look at which button was clicked and redirect to the appropriate page. So now I'm wondering if there's a better way to go about this or not. Anyways, here's the section of code from the form page with the submit buttons, to give a better picture of what I'm doing:

<div id="formButtons">
                    <input type="submit" id="extendedNotes" name="submission" value="Extended Notes" />
                    <input type="submit" id="southwareInfo" name="submission" value="SouthWare Info" />
                    <input type="submit" id="callNotes" name="submission" value="Call Notes" />
                    <input type="submit" id="saveChanges" name="submission" value="Save Changes" />
                    <input type="submit" id="newRecord" name="submission" value="New" />
                    <input type="submit" id="cancel" name="submission" value="Cancel (Back to Search)" />
                    <input type="submit" id="deleteRecord" name="submission" value="Delete" />
                    <input type="submit" id="printRecord" name="submission" value="Print" />
                </div><!-- end of formButtons div -->

And then here's the code from the page the form posts to:

<?php
    switch ($_POST['submission']) {
        case "Save Changes":
            header('Location: saveChanges.php');
            break;

        case "New":
            header('Location: newRecord.php');
            break;

        case "Cancel (Back to Search)":
            header('Location: customersearchView.php');
            break;

        case "Delete":
            header('Location: deleteRecord.php');
            break;

        case "Print":
            header('Location: printRecord.php');
            break;

        case "Extended Notes":
            header('Location: extendedNotes.php');
            break;

        case "SouthWare Info":
            header('Location: southwareInfo.php');
            break;

        case "Call Notes":
            header('Location: callNotes.php');
            break;

        default:
            header('Location: errors.php');
    }
0

my first and most important goal of coming across anything microsoft is finding how to export it as csv so i can actually do stuff with it - probably just that i never bothered learning any of the microsoft languages though.

for that example in php i can think of making it easier by making an array of the values so it gets simpler to change them eg.

formArray.php

<?php
$formRedirs = array(
				'SouthWare Info'=>'southwareInfo.php',
				'Call Notes'=>'callNotes.php',
				'Save Changes'=>'saveChanges.php',
				'New'=>'newRecord.php',
				'Cancel (Back to Search)'=>'customersearchView.php',
				'Delete'=>'deleteRecord.php',
				'Print'=>'printRecord.php',
				'Extended Notes'=>'extendedNotes.php'
				);
?>

formpage.php

<?php
require_once 'formArray.php';
<div id="formButtons">
<?php 
foreach($formRedirs as $k=>$v){
	echo "<input type='submit' id='southwareInfo' name='submission' value='{$k}' />\r\n";
}
?>
</div><!-- end of formButtons div -->

formprocess.php

<?php
require_once 'formArray.php';
if(in_array($_POST['submission'],$formRedirs)){
	header("Location: {$formRedirs[$_POST['submission']]}");
}else{
	header("Location: errors.php");
}
?>

you could even make a few sets of arrays for different options and include different ones based on the page

0

add an onclick to your buttons onclick="return this.form.action='path/to/page'" and skip the in between page then just post variable to the page you need them on

of course using array names in your forms is always easier for passing lots of variables

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.