• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Passing Variable Depending on users choice

Shuxclams

Diamond Member
So here is what I Want to do... I want the user to be able to add a new device to the inventory database(s). This page will help the person select a device type and send that infomation to the correct page ( Server, Laptop, Desktop, Printer, Misc...) The dropdown is populated by the main table holding the device type information. There is a secondary device table housing specific information about each device sub-type (i.e. HP Prolaint ML370 or HP LaserJet 2550N) that will be the intended table for the addition. In the code the page send the info to WHAT_EVER.php, I would really like for that page to be called depending on which device type they chose, i.e. choose Desktop Computer and they are sent to the "Desktop.php" page.

SHUX
 
Originally posted by: Shuxclams
So here is what I Want to do... I want the user to be able to add a new device to the inventory database(s). This page will help the person select a device type and send that infomation to the correct page ( Server, Laptop, Desktop, Printer, Misc...) The dropdown is populated by the main table holding the device type information. There is a secondary device table housing specific information about each device sub-type (i.e. HP Prolaint ML370 or HP LaserJet 2550N) that will be the intended table for the addition. In the code the page send the info to WHAT_EVER.php, I would really like for that page to be called depending on which device type they chose, i.e. choose Desktop Computer and they are sent to the "Desktop.php" page.

SHUX

doable. make your page self-processing:

<form action="<?php $_SERVER["PHP_SELF"]; ?>" method="post">


at the very top of your page:

<?php

if(isset($_POST["submit"])) {

if($_POST["device_type_name"] == "Desktop") {

header("Location: Desktop.php");

} else if$_POST["device_type_name"] == "Printer") {

header("Location: Printer.php");

} else if... //repeat till you have done all options.


}

?>

edit: forgot to close the isset() line.
 
"<?php $_SERVER["PHP_SELF"]; will always send me to SELF, it won't load the
if($_POST["device_type_name"] == "desktop") {
header("location😀esktop.php");

Logically would something grabbing the $_POST["device_type_name"] in the <form action=" do the trick?









SHUX
 
Back
Top