AblSysadmin
asked on
radio Button must have a ID when selecting it and moving to a other Page
Hi
I have a search Page with data on it. If I select a option from the radio button and move to a other page I need the id to be carried over. This is not working even if I place the follow code it in
<input name='changeCheck' type='radio' value='".$row['AssetID']." '/>
I have a search Page with data on it. If I select a option from the radio button and move to a other page I need the id to be carried over. This is not working even if I place the follow code it in
<input name='changeCheck' type='radio' value='".$row['AssetID']."
<?php
session_start();
?>
<html>
<body>
<?php include "Menu.php"; ?>
<!--<form action="action.php" method="post">-->
<?php
define("DB_HOST","server");
define("DB_USER","usename");
define("DB_PASS","password");
define("DB_NAME","database");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
$cost_code = $_POST['branch'];
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= '$cost_code'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0) exit("Cost code not found:<br>$query<br>Cost code var:$cost_code");
$_SESSION['cost_code'] = $_POST['branch'];
$row = mssql_fetch_assoc($result);
$get_assets = "SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = ".$row['BranchID']."";
$get_assets_result = mssql_query($get_assets, $db_connection);
if(!$get_assets_result) exit("Could not execute query:<br>$get_assets<br>".mssql_get_last_message());
if(mssql_num_rows($get_assets_result) == 0) exit("No assets found for branch");
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
//echo "<th>Change Order</th>";
//echo "<th>Select and Update</th>";
//echo "<th>Move Asset</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
//echo "<td>".$row['Incident']."</td>";
//echo "<td>".$row['changeorder']."</td>";
//echo "<td><a href='action.php?id=".$row['AssetID']."'>Action Asset</a></td>";
//echo "<td><a href='asset_move.php?id=".$row['AssetID']."'>MOVE ASSET</a></td>";
echo "</tr>";
} // end while
echo "</table>";
echo "<br>";
?>
<!--<input type="submit" value="Action">
</form>-->
<?php
if(isset($_POST["submit_action"])){
switch ($_POST["submit_action"]) {
case "Register a Transfer": header("Location: asset_move.php"); break;
case "Place into storage": header("Location: place_into_storage.php"); break;
case "Register as Broken": header("Location: register_as_broken.php"); break;
case "Decommission": header("Location: decommission.php"); break;
}
}
?>
<form action="#" method="post">
<input type="submit" value="Register a Transfer" name="submit_action" />
<input type="submit" value="Place into storage" name="submit_action"/>
<input type="submit" value="Register as Broken" name="submit_action"/>
<input type="submit" value="Decommission" name="submit_action"/>
</form>
</body>
</html>
Checkboxes and radioboxes do only get carried over when they're set. If they're not set, not even the environment variables (e.g. $_REQUEST, $_GET or $_POST) show them.
As gamebits already suggested, you need to set the value of this input element to checked, but what puzzles me more is that you seem to do redirects depending on what action the user has chosen, is that right?
form variables will usually not survive redirects unless you store them into your $_SESSION array...
As gamebits already suggested, you need to set the value of this input element to checked, but what puzzles me more is that you seem to do redirects depending on what action the user has chosen, is that right?
form variables will usually not survive redirects unless you store them into your $_SESSION array...
ASKER
Hi
I only want the id of the selected record when i press any button.
E.g.
I have 5 records dispalyed in my search page. When I select the first record it should have a id. So when I press any button dispalyed on my search page (e.g. Register as Broken) it will taek me to the Register as Broken.php page with the id in the URL
e.g http://usvddev/AssetManagement/register_as_broken.php/id19
The id of the record si displayed because when I updated the record in the database it know awhat to update
I only want the id of the selected record when i press any button.
E.g.
I have 5 records dispalyed in my search page. When I select the first record it should have a id. So when I press any button dispalyed on my search page (e.g. Register as Broken) it will taek me to the Register as Broken.php page with the id in the URL
e.g http://usvddev/AssetManagement/register_as_broken.php/id19
The id of the record si displayed because when I updated the record in the database it know awhat to update
ASKER
Hi
I have placed this code in to get the ID
<form action="#" method="post">
<input type="hidden" value="<?php echo $_GET['id']; ?>" name="id">
<input type="submit" value="Register a Transfer" name="submit_action"/>
<input type="submit" value="Place into storage" name="submit_action"/>
<input type="submit" value="Register as Broken" name="submit_action"/>
<input type="submit" value="Decommission" name="submit_action"/>
</form>
But when looking at the source code I do not get the ID. The value field is blank
"<input type="hidden" value="" name="id">"
I have placed this code in to get the ID
<form action="#" method="post">
<input type="hidden" value="<?php echo $_GET['id']; ?>" name="id">
<input type="submit" value="Register a Transfer" name="submit_action"/>
<input type="submit" value="Place into storage" name="submit_action"/>
<input type="submit" value="Register as Broken" name="submit_action"/>
<input type="submit" value="Decommission" name="submit_action"/>
</form>
But when looking at the source code I do not get the ID. The value field is blank
"<input type="hidden" value="" name="id">"
If the id is coming from a database query you would have to use something like this
<input type="hidden" value="<?php echo '".$row['AssetID']."' ?>" name="id">
<input type="hidden" value="<?php echo '".$row['AssetID']."' ?>" name="id">
ASKER
Hi
I am trying to search for this Error
"Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\Inetpub\wwwroot\AssetMa nagement\s earch.php on line 131"
in my code
<form action="#" method="post">
<input type="hidden" value="<?php echo'".$row['AssetID']."' ?>" name="id"/>
<input type="submit" value="Register a Transfer" name="submit_action"/>
<input type="submit" value="Place into storage" name="submit_action"/>
<input type="submit" value="Register as Broken" name="submit_action"/>
<input type="submit" value="Decommission" name="submit_action"/>
</form>
I am trying to search for this Error
"Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\Inetpub\wwwroot\AssetMa
in my code
<form action="#" method="post">
<input type="hidden" value="<?php echo'".$row['AssetID']."' ?>" name="id"/>
<input type="submit" value="Register a Transfer" name="submit_action"/>
<input type="submit" value="Place into storage" name="submit_action"/>
<input type="submit" value="Register as Broken" name="submit_action"/>
<input type="submit" value="Decommission" name="submit_action"/>
</form>
ASKER
Any Assistance
ASKER
Good Morning All
Any assistance on this matter with the ID
Any assistance on this matter with the ID
ASKER
HI
I have correct this but receiving and Error
Line: 17
Char: 1
Error: 'this.form.post_page' is null or not an object
Code: 0
URL : http://usvddev/AssetManagement/search.php
I have correct this but receiving and Error
Line: 17
Char: 1
Error: 'this.form.post_page' is null or not an object
Code: 0
URL : http://usvddev/AssetManagement/search.php
<?php
session_start();
if (isset($_POST['post_page'])){
if ($_POST['post_page'] =='page_1'){header("Location: asset_move.php");exit;}
if ($_POST['post_page'] =='page_2'){header("Location: place_into_storage.php");exit;}
if ($_POST['post_page'] =='page_3'){header("Location: register_as_broken.php");exit;}
if ($_POST['post_page'] =='page_4'){header("Location: decommission.php");exit;}
}
?>
<html>
<body>
<?php include "Menu.php"; ?>
<!--<form action="action.php" method="post">-->
<?php
define("DB_HOST","server");
define("DB_USER","username");
define("DB_PASS","password");
define("DB_NAME","database");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
$cost_code = $_POST['branch'];
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= '$cost_code'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0) exit("Cost code not found:<br>$query<br>Cost code var:$cost_code");
$_SESSION['cost_code'] = $_POST['branch'];
$row = mssql_fetch_assoc($result);
$get_assets = "SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = ".$row['BranchID']."";
$get_assets_result = mssql_query($get_assets, $db_connection);
if(!$get_assets_result) exit("Could not execute query:<br>$get_assets<br>".mssql_get_last_message());
if(mssql_num_rows($get_assets_result) == 0) exit("No assets found for branch");
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
//echo "<th>Change Order</th>";
//echo "<th>Select and Update</th>";
//echo "<th>Move Asset</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
//echo "<td>".$row['Incident']."</td>";
//echo "<td>".$row['changeorder']."</td>";
//echo "<td><a href='action.php?id=".$row['AssetID']."'>Action Asset</a></td>";
//echo "<td><a href='asset_move.php?id=".$row['AssetID']."'>MOVE ASSET</a></td>";
echo "</tr>";
} //end while
echo "</table>";
echo "<br>";
?>
<form action="" method="get">
<input type="hidden" value="<?php echo"'".$row['AssetID']."'" ?>" name="id"/>
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_page.value='page_1';this.form.submit();">
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_page.value='page_2';this.form.submit();">
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_page.value='page_3';this.form.submit();">
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_page.value='page_4';this.form.submit();">
</form>
</body>
</html>
Look at the HTML that is produced. Where is the form element whose name is "post_page"?
Also, don't use "id" as a name. id is a element attribute and ....
this.form.id = "???" is ambiguous. Do you mean the id attribute of the form or the form element whose name is id?
Try ...
<input type="hidden" value="<?php echo"'".$row['AssetID']."' " ?>" name="post_page"/>
and see what happens.
Also, don't use "id" as a name. id is a element attribute and ....
this.form.id = "???" is ambiguous. Do you mean the id attribute of the form or the form element whose name is id?
Try ...
<input type="hidden" value="<?php echo"'".$row['AssetID']."'
and see what happens.
ASKER
Hi
I have changes it but when I select e.g Register a Transfer it does not go to the page asset_move.php. Does says The page cannot be found and the URL links to "http://usvddev/AssetManagement/post_page"
I will need to button to direct to the pages in the code
I have changes it but when I select e.g Register a Transfer it does not go to the page asset_move.php. Does says The page cannot be found and the URL links to "http://usvddev/AssetManagement/post_page"
I will need to button to direct to the pages in the code
ASKER
Hi
I have test it and removed "post_page " from
<form action="post_page" method="post" > and look like this now
<form action="" method="post" > and it does to the pages but the id does not pull through in the url
http://usvddev/AssetManagement/decommission.php ?
I have test it and removed "post_page " from
<form action="post_page" method="post" > and look like this now
<form action="" method="post" > and it does to the pages but the id does not pull through in the url
http://usvddev/AssetManagement/decommission.php ?
THat is because you are "post"ing the form. Try "get"ting the form.
<form action="" method="get">
<form action="" method="get">
ASKER
Hi have tried get and its not working because I am gettting a Error
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
And the URL looks like
http://usvddev/AssetManagement/search.php?post_page=page_1
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
And the URL looks like
http://usvddev/AssetManagement/search.php?post_page=page_1
If you use <form method="post"> you will need to use $_POST
If you use <form method="get"> you will need to use $_GET
In your PHP code you have...
$cost_code = $_POST['branch'];
So, at a minimum this should be ...
$cost_code = $_GET['branch'];
but you've not got an <input name="branch" xxxxxxx> in the <form>.
If you use <form method="get"> you will need to use $_GET
In your PHP code you have...
$cost_code = $_POST['branch'];
So, at a minimum this should be ...
$cost_code = $_GET['branch'];
but you've not got an <input name="branch" xxxxxxx> in the <form>.
Ah, remember a HTML form can only pick up <inputs>, <selects>, etc between <form> and </form>
So, if you have something like this ...
<input type="hidden" name="foo" value="bar" />
<form method="get" action="somewhere.php">
<input type="submit" />
</form>
$_GET['foo'] will NOT exist.
So, if you have something like this ...
<input type="hidden" name="foo" value="bar" />
<form method="get" action="somewhere.php">
<input type="submit" />
</form>
$_GET['foo'] will NOT exist.
ASKER
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= " $_GET['branch'];
I have added the following above I still not gettinf the ID
I have added the following above I still not gettinf the ID
<?php
session_start();
if (isset($_POST['post_page'])){
if ($_POST['post_page'] =='page_1'){header("Location: asset_move.php");exit;}
if ($_POST['post_page'] =='page_2'){header("Location: place_into_storage.php");exit;}
if ($_POST['post_page'] =='page_3'){header("Location: register_as_broken.php");exit;}
if ($_POST['post_page'] =='page_4'){header("Location: decommission.php");exit;}
}
?>
<html>
<body>
<?php include "Menu.php"; ?>
<!--<form action="action.php" method="post">-->
<?php
define("DB_HOST","servername");
define("DB_USER","username");
define("DB_PASS","password");
define("DB_NAME","database");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
$cost_code = $_POST['branch'];
//$query = "SELECT BranchID FROM Branch WHERE branchcostcode= '$cost_code'";
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= " $_GET['branch'];
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0) exit("Cost code not found:<br>$query<br>Cost code var:$cost_code");
$_SESSION['cost_code'] = $_POST['branch'];
$row = mssql_fetch_assoc($result);
$get_assets = "SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = ".$row['BranchID']."";
$get_assets_result = mssql_query($get_assets, $db_connection);
if(!$get_assets_result) exit("Could not execute query:<br>$get_assets<br>".mssql_get_last_message());
if(mssql_num_rows($get_assets_result) == 0) exit("No assets found for branch");
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
//echo "<th>Change Order</th>";
//echo "<th>Select and Update</th>";
//echo "<th>Move Asset</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
//echo "<td>".$row['Incident']."</td>";
//echo "<td>".$row['changeorder']."</td>";
//echo "<td><a href='action.php?id=".$row['AssetID']."'>Action Asset</a></td>";
//echo "<td><a href='asset_move.php?id=".$row['AssetID']."'>MOVE ASSET</a></td>";
echo "</tr>";
} //end while
echo "</table>";
echo "<br>";
?>
<form action="" method="get">
<input type="hidden" value="<?php echo"'".$row['AssetID']."'" ?>" name="post_page"/>
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_page.value='page_1';this.form.submit();">
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_page.value='page_2';this.form.submit();">
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_page.value='page_3';this.form.submit();">
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_page.value='page_4';this.form.submit();">
</form>
</body>
</html>
Can you show the HTML output. If you have FireFox, take a look at getting the HTML Validator extension to auto check your code.
I can see the checkbox you've got defined is still outside of the <form></form> tags, so won't be included!
And the PHP code at the top is still $_POST and not $_GET.
<form method="post"> and $_POST
_OR_
<form method="get"> and $_GET
I can see the checkbox you've got defined is still outside of the <form></form> tags, so won't be included!
And the PHP code at the top is still $_POST and not $_GET.
<form method="post"> and $_POST
_OR_
<form method="get"> and $_GET
ASKER
Good Morning
I am not sure I am i a blond but I do not seems to get this right.
At the search screen here is my source code
html>
Home
Whats New
<!--Download-->
Search
Add Asset
<!--<form action="action.php" method="post">-->
SelectDeviceTypeDeviceMake DeviceMode lSerialCos t CodeDomain UserDate ModifiedDate CreatedStatusChange Order<input name='changeCheck' type='radio' value='17'/>DesktopHP CompaqDeskpro ENPTDXCVB345678NTOP10IT06A nthonio200 8/07/09200 8/07/09Reg isteredCO0 8353<input name='changeCheck' type='radio' value='18'/>DesktopHP CompaqDeskpro ENPTDXCVB345678NTOP10IT06A nthonio200 8/07/09200 8/07/09Reg isteredCO0 8353<input name='changeCheck' type='radio' value='19'/>DesktopHP CompaqDeskpro ENPTDXCVB345678NTOP10IT06A nthonio200 8/07/09200 8/07/09Reg isteredCO0 8353<input name='changeCheck' type='radio' value='20'/>DesktopHP CompaqDeskpro ENPTDXCVB345678NTOP10IT06A nthonio200 8/07/09200 8/07/09Reg isteredCO0 8353<input name='changeCheck' type='radio' value='21'/>DesktopHP CompaqDeskpro ENPTRSXCVBNMNTOP10IT06BOOY SEN2008/07 /092008/07 /09Registe redCO08353
<form action="" method="get">
<input type="hidden" value="''" name="post_page"/>
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_pa ge.value=' page_1';th is.form.su bmit();">
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_pa ge.value=' page_2';th is.form.su bmit();">
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_pa ge.value=' page_3';th is.form.su bmit();">
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_pa ge.value=' page_4';th is.form.su bmit();">
</form>
When searching I am gettin gettin the Error
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
URL
http://usvddev/AssetManagement/search.php?post_page=page_1
I am not sure I am i a blond but I do not seems to get this right.
At the search screen here is my source code
html>
Home
Whats New
<!--Download-->
Search
Add Asset
<!--<form action="action.php" method="post">-->
SelectDeviceTypeDeviceMake
<form action="" method="get">
<input type="hidden" value="''" name="post_page"/>
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_pa
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_pa
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_pa
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_pa
</form>
When searching I am gettin gettin the Error
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
URL
http://usvddev/AssetManagement/search.php?post_page=page_1
<?php
session_start();
if (isset($_GET['post_page'])){
if ($_POST['post_page'] =='page_1'){header("Location: asset_move.php");exit;}
if ($_POST['post_page'] =='page_2'){header("Location: place_into_storage.php");exit;}
if ($_POST['post_page'] =='page_3'){header("Location: register_as_broken.php");exit;}
if ($_POST['post_page'] =='page_4'){header("Location: decommission.php");exit;}
}
?>
<html>
<body>
<?php include "Menu.php"; ?>
<!--<form action="action.php" method="post">-->
<?php
define("DB_HOST","localhost");
define("DB_USER","ServiceDesk");
define("DB_PASS","ServiceDesk");
define("DB_NAME","AssetDB");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
$cost_code = $_POST['branch'];
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= '$cost_code'";
//$query = "SELECT BranchID FROM Branch WHERE branchcostcode= " $_GET['branch'];
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0) exit("Cost code not found:<br>$query<br>Cost code var:$cost_code");
$_SESSION['cost_code'] = $_POST['branch'];
$row = mssql_fetch_assoc($result);
$get_assets = "SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = ".$row['BranchID']."";
$get_assets_result = mssql_query($get_assets, $db_connection);
if(!$get_assets_result) exit("Could not execute query:<br>$get_assets<br>".mssql_get_last_message());
if(mssql_num_rows($get_assets_result) == 0) exit("No assets found for branch");
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
//echo "<th>Change Order</th>";
//echo "<th>Select and Update</th>";
//echo "<th>Move Asset</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
//echo "<td>".$row['Incident']."</td>";
//echo "<td>".$row['changeorder']."</td>";
//echo "<td><a href='action.php?id=".$row['AssetID']."'>Action Asset</a></td>";
//echo "<td><a href='asset_move.php?id=".$row['AssetID']."'>MOVE ASSET</a></td>";
echo "</tr>";
} //end while
echo "</table>";
echo "<br>";
?>
<form action="" method="get">
<input type="hidden" value="<?php echo"'".$row['AssetID']."'" ?>" name="post_page"/>
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_page.value='page_1';this.form.submit();">
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_page.value='page_2';this.form.submit();">
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_page.value='page_3';this.form.submit();">
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_page.value='page_4';this.form.submit();">
</form>
</body>
</html>
Ok.
Here is the HTML of your form ...
<form action="" method="get">
<input type="hidden" value="''" name="post_page"/>
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_pa ge.value=' page_1';th is.form.su bmit();">
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_pa ge.value=' page_2';th is.form.su bmit();">
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_pa ge.value=' page_3';th is.form.su bmit();">
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_pa ge.value=' page_4';th is.form.su bmit();">
</form>
Where is form element with a name="branch"?
No branch means $_GET['branch'] isn't going to work.
Add this to the bottom of your code. It will show you what data is external available to your script. If it is not in this output, it has to come from somewhere else and PHP isn't very good at telepathy!
Here is the HTML of your form ...
<form action="" method="get">
<input type="hidden" value="''" name="post_page"/>
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_pa
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_pa
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_pa
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_pa
</form>
Where is form element with a name="branch"?
No branch means $_GET['branch'] isn't going to work.
Add this to the bottom of your code. It will show you what data is external available to your script. If it is not in this output, it has to come from somewhere else and PHP isn't very good at telepathy!
echo
'<pre>',
'$_COOKIE = ', var_export($_COOKIE, True), PHP_EOL,
'$_GET = ', var_export($_GET, True), PHP_EOL,
'$_POST = ', var_export($_POST, True), PHP_EOL,
'$_SESSION = ', var_export($_SESSION, True), PHP_EOL,
'</pre>';
Ah. Does this page get supplied a branch ID, you show the data on the screen and then you press a button? And THEN it loses the branch?
You need to add the "branch" to the form.
<input type="hidden" name="branch" value="<?php echo $_POST['branch']; ?>" />
or
<input type="hidden" name="branch" value="<?php echo $_GET['branch']; ?>" />
Depending upon if you want to use POST or GET. If the page can be bookmarked, then GET is the better option.
POST should be used to invoke a change in state on the server (say updating a database).
GET should be used to retrieve something from the server (say like a search page or a list of assets, etc.).
You need to add the "branch" to the form.
<input type="hidden" name="branch" value="<?php echo $_POST['branch']; ?>" />
or
<input type="hidden" name="branch" value="<?php echo $_GET['branch']; ?>" />
Depending upon if you want to use POST or GET. If the page can be bookmarked, then GET is the better option.
POST should be used to invoke a change in state on the server (say updating a database).
GET should be used to retrieve something from the server (say like a search page or a list of assets, etc.).
ASKER
Hi
Everytime i click a button the post_page => value changes.
This is only when I use
<input type="hidden" name="branch" value="<?php echo $_POST['branch']; ?>" />
$_POST = array (
'post_page' => 'page_3',
'branch' => 'NTOP10IT06',
$_COOKIE = array (
'PHPSESSID' => 'a12f7d9138226f92be0cfcdf0 4030bec',
)
$_GET = array (
)
$_POST = array (
'post_page' => 'page_2',
'branch' => 'NTOP10IT06',
)
$_SESSION = array (
'cost_code' => 'NTOP10IT06',
)
Everytime i click a button the post_page => value changes.
This is only when I use
<input type="hidden" name="branch" value="<?php echo $_POST['branch']; ?>" />
$_POST = array (
'post_page' => 'page_3',
'branch' => 'NTOP10IT06',
$_COOKIE = array (
'PHPSESSID' => 'a12f7d9138226f92be0cfcdf0
)
$_GET = array (
)
$_POST = array (
'post_page' => 'page_2',
'branch' => 'NTOP10IT06',
)
$_SESSION = array (
'cost_code' => 'NTOP10IT06',
)
ASKER
Hi
When I use
<input type="hidden" name="branch" value="<?php echo $_GET['branch']; ?>" />
And press any button on my form I am getting
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
URL
http://usvddev/AssetManagement/search.php
When I use
<input type="hidden" name="branch" value="<?php echo $_GET['branch']; ?>" />
And press any button on my form I am getting
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
URL
http://usvddev/AssetManagement/search.php
So we go with $_POST! Excellent.
ASKER
Using Post
The page does not go to the next page.
This is mu source code from the search page. and when selecting a radio button I do not see the ID value
The page does not go to the next page.
This is mu source code from the search page. and when selecting a radio button I do not see the ID value
<html>
<body>
<table>
<tr>
<td><a href="HomePage.php">Home</a></td>
<td><a href="WhatsNew.php">Whats New</a></td>
<!--<td><a href="Download.php">Download</a></td>-->
<td><a href="SearchPage.php">Search</a></td>
<td><a href="create_asset.php">Add Asset</a></td>
</tr>
</table><br>
<!--<form action="action.php" method="post">-->
<table border="2" cellspacing="1"><tr><th>Select</th><th>DeviceType</th><th>DeviceMake</th><th>DeviceModel</th><th>Serial</th><th>Cost Code</th><th>Domain User</th><th>Date Modified</th><th>Date Created</th><th>Status</th><th>Change Order</th></tr><tr><td><input name='changeCheck' type='radio' value='17'/></td><td>Desktop</td><td>HP Compaq</td><td>Deskpro EN</td><td>PTDXCVB345678</td><td>NTOP10IT06</td><td>Anthonio</td><td>2008/07/09</td><td>2008/07/09</td><td>Registered</td><td>CO08353</td></tr><tr><td><input name='changeCheck' type='radio' value='18'/></td><td>Desktop</td><td>HP Compaq</td><td>Deskpro EN</td><td>PTDXCVB345678</td><td>NTOP10IT06</td><td>Anthonio</td><td>2008/07/09</td><td>2008/07/09</td><td>Registered</td><td>CO08353</td></tr><tr><td><input name='changeCheck' type='radio' value='19'/></td><td>Desktop</td><td>HP Compaq</td><td>Deskpro EN</td><td>PTDXCVB345678</td><td>NTOP10IT06</td><td>Anthonio</td><td>2008/07/09</td><td>2008/07/09</td><td>Registered</td><td>CO08353</td></tr><tr><td><input name='changeCheck' type='radio' value='20'/></td><td>Desktop</td><td>HP Compaq</td><td>Deskpro EN</td><td>PTDXCVB345678</td><td>NTOP10IT06</td><td>Anthonio</td><td>2008/07/09</td><td>2008/07/09</td><td>Registered</td><td>CO08353</td></tr><tr><td><input name='changeCheck' type='radio' value='21'/></td><td>Desktop</td><td>HP Compaq</td><td>Deskpro EN</td><td>PTRSXCVBNM</td><td>NTOP10IT06</td><td>BOOYSEN</td><td>2008/07/09</td><td>2008/07/09</td><td>Registered</td><td>CO08353</td></tr></table><br>
<form action="" method="post">
<input type="hidden" value="''" name="post_page"/>
<input type="hidden" name="branch" value="NTOP10IT06" /> <!-- New Code Added-->
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_page.value='page_1';this.form.submit();">
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_page.value='page_2';this.form.submit();">
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_page.value='page_3';this.form.submit();">
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_page.value='page_4';this.form.submit();">
</form>
</body>
</html>
Ok. 2 PHP scripts.
The first shows what your code looks like with all the form elements wrapped in a green box and the form in a red one.
The second script is the same form, but corrected to do what I think you are wanting to do.
Notice the different location of the <form> tag ?
The first shows what your code looks like with all the form elements wrapped in a green box and the form in a red one.
The second script is the same form, but corrected to do what I think you are wanting to do.
Notice the different location of the <form> tag ?
<?php
session_start();
$s_DebugOutput =
'$_COOKIE = ' . var_export($_COOKIE, True) . PHP_EOL .
'$_GET = ' . var_export($_GET, True) . PHP_EOL .
'$_POST = ' . var_export($_POST, True) . PHP_EOL .
'$_SESSION = ' . var_export($_SESSION, True) . PHP_EOL;
echo <<< END_HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Simple example of GET/POST</title>
<style type="text/css">
input
{
border : 2px solid green;
padding : 3px;
}
form
{
border : 2px solid red;
padding : 3px;
}
</style>
</head>
<body>
<div>
<h1>Results from form</h1>
<pre>{$s_DebugOutput}</pre>
</div>
<div>
<h1>Form</h1>
<table>
<tr>
<td><a href="HomePage.php">Home</a></td>
<td><a href="WhatsNew.php">Whats New</a></td>
<!--<td><a href="Download.php">Download</a></td>-->
<td><a href="SearchPage.php">Search</a></td>
<td><a href="create_asset.php">Add Asset</a></td>
</tr>
</table>
<br />
<!--
Notice that this block has been commented out
<form action="action.php" method="post">
-->
<table border="2" cellspacing="1">
<tr>
<th>Select</th>
<th>DeviceType</th>
<th>DeviceMake</th>
<th>DeviceModel</th>
<th>Serial</th>
<th>Cost Code</th>
<th>Domain User</th>
<th>Date Modified</th>
<th>Date Created</th>
<th>Status</th>
<th>Change Order</th>
</tr>
<tr>
<td>
<input name="changeCheck" type="radio" value="17" />
</td>
<td>Desktop</td>
<td>HP Compaq</td>
<td>Deskpro EN</td>
<td>PTDXCVB345678</td>
<td>NTOP10IT06</td>
<td>Anthonio</td>
<td>2008/07/09</td>
<td>2008/07/09</td>
<td>Registered</td>
<td>CO08353</td>
</tr>
<tr>
<td>
<input name="changeCheck" type="radio" value="18" />
</td>
<td>Desktop</td>
<td>HP Compaq</td>
<td>Deskpro EN</td>
<td>PTDXCVB345678</td>
<td>NTOP10IT06</td>
<td>Anthonio</td>
<td>2008/07/09</td>
<td>2008/07/09</td>
<td>Registered</td>
<td>CO08353</td>
</tr>
<tr>
<td>
<input name="changeCheck" type="radio" value="19" />
</td>
<td>Desktop</td>
<td>HP Compaq</td>
<td>Deskpro EN</td>
<td>PTDXCVB345678</td>
<td>NTOP10IT06</td>
<td>Anthonio</td>
<td>2008/07/09</td>
<td>2008/07/09</td>
<td>Registered</td>
<td>CO08353</td>
</tr>
<tr>
<td>
<input name="changeCheck" type="radio" value="20" />
</td>
<td>Desktop</td>
<td>HP Compaq</td>
<td>Deskpro EN</td>
<td>PTDXCVB345678</td>
<td>NTOP10IT06</td>
<td>Anthonio</td>
<td>2008/07/09</td>
<td>2008/07/09</td>
<td>Registered</td>
<td>CO08353</td>
</tr>
<tr>
<td>
<input name="changeCheck" type="radio" value="21" />
</td>
<td>Desktop</td>
<td>HP Compaq</td>
<td>Deskpro EN</td>
<td>PTRSXCVBNM</td>
<td>NTOP10IT06</td>
<td>BOOYSEN</td>
<td>2008/07/09</td>
<td>2008/07/09</td>
<td>Registered</td>
<td>CO08353</td>
</tr>
</table>
<br />
<form action="" method="post">
<div>
<input type="hidden" value="" name="post_page" />
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_page.value='page_1';this.form.submit();" />
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_page.value='page_2';this.form.submit();" />
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_page.value='page_3';this.form.submit();" />
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_page.value='page_4';this.form.submit();" />
</div>
</form>
</div>
</body>
</html>
END_HTML;
And the corrected script.
<?php
session_start();
$s_DebugOutput =
'$_COOKIE = ' . var_export($_COOKIE, True) . PHP_EOL .
'$_GET = ' . var_export($_GET, True) . PHP_EOL .
'$_POST = ' . var_export($_POST, True) . PHP_EOL .
'$_SESSION = ' . var_export($_SESSION, True) . PHP_EOL;
echo <<< END_HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Simple example of GET/POST</title>
<style type="text/css">
input
{
border : 2px solid green;
padding : 3px;
}
form
{
border : 2px solid red;
padding : 3px;
}
</style>
</head>
<body>
<div>
<h1>Results from form</h1>
<pre>{$s_DebugOutput}</pre>
</div>
<div>
<h1>Form</h1>
<table>
<tr>
<td><a href="HomePage.php">Home</a></td>
<td><a href="WhatsNew.php">Whats New</a></td>
<!--<td><a href="Download.php">Download</a></td>-->
<td><a href="SearchPage.php">Search</a></td>
<td><a href="create_asset.php">Add Asset</a></td>
</tr>
</table>
<br />
<form action="" method="post">
<table border="2" cellspacing="1">
<tr>
<th>Select</th>
<th>DeviceType</th>
<th>DeviceMake</th>
<th>DeviceModel</th>
<th>Serial</th>
<th>Cost Code</th>
<th>Domain User</th>
<th>Date Modified</th>
<th>Date Created</th>
<th>Status</th>
<th>Change Order</th>
</tr>
<tr>
<td>
<input name="changeCheck" type="radio" value="17" />
</td>
<td>Desktop</td>
<td>HP Compaq</td>
<td>Deskpro EN</td>
<td>PTDXCVB345678</td>
<td>NTOP10IT06</td>
<td>Anthonio</td>
<td>2008/07/09</td>
<td>2008/07/09</td>
<td>Registered</td>
<td>CO08353</td>
</tr>
<tr>
<td>
<input name="changeCheck" type="radio" value="18" />
</td>
<td>Desktop</td>
<td>HP Compaq</td>
<td>Deskpro EN</td>
<td>PTDXCVB345678</td>
<td>NTOP10IT06</td>
<td>Anthonio</td>
<td>2008/07/09</td>
<td>2008/07/09</td>
<td>Registered</td>
<td>CO08353</td>
</tr>
<tr>
<td>
<input name="changeCheck" type="radio" value="19" />
</td>
<td>Desktop</td>
<td>HP Compaq</td>
<td>Deskpro EN</td>
<td>PTDXCVB345678</td>
<td>NTOP10IT06</td>
<td>Anthonio</td>
<td>2008/07/09</td>
<td>2008/07/09</td>
<td>Registered</td>
<td>CO08353</td>
</tr>
<tr>
<td>
<input name="changeCheck" type="radio" value="20" />
</td>
<td>Desktop</td>
<td>HP Compaq</td>
<td>Deskpro EN</td>
<td>PTDXCVB345678</td>
<td>NTOP10IT06</td>
<td>Anthonio</td>
<td>2008/07/09</td>
<td>2008/07/09</td>
<td>Registered</td>
<td>CO08353</td>
</tr>
<tr>
<td>
<input name="changeCheck" type="radio" value="21" />
</td>
<td>Desktop</td>
<td>HP Compaq</td>
<td>Deskpro EN</td>
<td>PTRSXCVBNM</td>
<td>NTOP10IT06</td>
<td>BOOYSEN</td>
<td>2008/07/09</td>
<td>2008/07/09</td>
<td>Registered</td>
<td>CO08353</td>
</tr>
</table>
<br />
<div>
<input type="hidden" value="" name="post_page" />
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_page.value='page_1';this.form.submit();" />
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_page.value='page_2';this.form.submit();" />
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_page.value='page_3';this.form.submit();" />
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_page.value='page_4';this.form.submit();" />
</div>
</form>
</div>
</body>
</html>
END_HTML;
Just noticed that in Firefox 3 the radio groups don't get a pretty border. They do in IE7 though.
ASKER
My new php looks like this. But when I select a button i still get the Error
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
URL:
http://usvddev/AssetManagement/search.php
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
URL:
http://usvddev/AssetManagement/search.php
<?php
session_start();
if (isset($_GET['post_page'])){
if ($_POST['post_page'] =='page_1'){header("Location: asset_move.php");exit;}
if ($_POST['post_page'] =='page_2'){header("Location: place_into_storage.php");exit;}
if ($_POST['post_page'] =='page_3'){header("Location: register_as_broken.php");exit;}
if ($_POST['post_page'] =='page_4'){header("Location: decommission.php");exit;}
}
?>
<html>
<body>
<?php include "Menu.php"; ?>
<!--<form action="action.php" method="post">-->
<form action="" method="post">
<?php
define("DB_HOST","localhost");
define("DB_USER","ServiceDesk");
define("DB_PASS","ServiceDesk");
define("DB_NAME","AssetDB");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
$cost_code = $_POST['branch'];
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= '$cost_code'";
//$query = "SELECT BranchID FROM Branch WHERE branchcostcode= " $_GET['branch'];
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0) exit("Cost code not found:<br>$query<br>Cost code var:$cost_code");
$_SESSION['cost_code'] = $_POST['branch'];
$row = mssql_fetch_assoc($result);
$get_assets = "SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = ".$row['BranchID']."";
$get_assets_result = mssql_query($get_assets, $db_connection);
if(!$get_assets_result) exit("Could not execute query:<br>$get_assets<br>".mssql_get_last_message());
if(mssql_num_rows($get_assets_result) == 0) exit("No assets found for branch");
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
//echo "<th>Change Order</th>";
//echo "<th>Select and Update</th>";
//echo "<th>Move Asset</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
//echo "<td>".$row['Incident']."</td>";
//echo "<td>".$row['changeorder']."</td>";
//echo "<td><a href='action.php?id=".$row['AssetID']."'>Action Asset</a></td>";
//echo "<td><a href='asset_move.php?id=".$row['AssetID']."'>MOVE ASSET</a></td>";
echo "</tr>";
} //end while
echo "</table>";
echo "<br>";
?>
<input type="hidden" value="" name="post_page" />
<input type="button" name="page_1" value="Register a Transfer" onclick="this.form.post_page.value='page_1';this.form.submit();">
<input type="button" name="page_2" value="Place into storage" onclick="this.form.post_page.value='page_2';this.form.submit();">
<input type="button" name="page_3" value="Register as Broken" onclick="this.form.post_page.value='page_3';this.form.submit();">
<input type="button" name="page_4" value="Decommission" onclick="this.form.post_page.value='page_4';this.form.submit();">
</form>
</body>
</html>
Add in the debug we had ...
echo
'
And can you show me an online version. The URL you gave isn't valid.
echo
'
',
'$_COOKIE = ', var_export($_COOKIE, True), PHP_EOL,
'$_GET = ', var_export($_GET, True), PHP_EOL,
'$_POST = ', var_export($_POST, True), PHP_EOL,
'$_SESSION = ', var_export($_SESSION, True), PHP_EOL,
'
';And can you show me an online version. The URL you gave isn't valid.
ASKER
When I placve the debug in i get
$_COOKIE = array (
'PHPSESSID' => '0502de6fe79a0fa4c273143b9 773cad4',
)
$_GET = array (
)
$_POST = array (
'changeCheck' => '21',
'post_page' => 'page_4',
)
$_SESSION = array (
'cost_code' => 'NTOP10IT06',
)
Home Whats New Search Add Asset
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
$_COOKIE = array (
'PHPSESSID' => '0502de6fe79a0fa4c273143b9
)
$_GET = array (
)
$_POST = array (
'changeCheck' => '21',
'post_page' => 'page_4',
)
$_SESSION = array (
'cost_code' => 'NTOP10IT06',
)
Home Whats New Search Add Asset
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
Okay, running around in circles.
For the PHP code to extract data from $_GET or $_POST, it has to have been supplied.
Where does cost code from from? Follow it back to the source.
You are not supplying it from the form you are showing.
I've shown you the variables that you ARE sending.
Basically you are asking for something which you've not supplied. Until you know where it is supplied, I can't help you.
For the PHP code to extract data from $_GET or $_POST, it has to have been supplied.
Where does cost code from from? Follow it back to the source.
You are not supplying it from the form you are showing.
I've shown you the variables that you ARE sending.
Basically you are asking for something which you've not supplied. Until you know where it is supplied, I can't help you.
ASKER
Hi
This its how it works. User will will go to the SearchPage.php and type the costcode and it will go to the search.php. This will then display all the assets link to the Cost Code that the user typed. The user then have a option to select via the radion button a option to update using the different buttons.
SearchPage.php
------------------------
<?php
session_start();
?>
<form action="search.php" method="post">
<input type="text" name="branch">
<input type="submit" value="Submit">
</form>
This its how it works. User will will go to the SearchPage.php and type the costcode and it will go to the search.php. This will then display all the assets link to the Cost Code that the user typed. The user then have a option to select via the radion button a option to update using the different buttons.
SearchPage.php
------------------------
<?php
session_start();
?>
<form action="search.php" method="post">
<input type="text" name="branch">
<input type="submit" value="Submit">
</form>
Ok, and on search.php, can you put this at the VERY top of the script.
<?php
echo '
exit;
And tell me what output you get when you press submit on the SearchPage page.
<?php
echo '
';
var_dump($_POST);
echo '
';exit;
And tell me what output you get when you press submit on the SearchPage page.
I suspect you get the answer you want.
Now, if you take out the exit in the code, what do you get when you press submit on the SearchPage page?
The right answer still?
But it all goes horribly wrong when you choose one of the buttons?
The reason is that nothing is remembered.
The passing of "branch" was not remembered.
Either put the branch in the session ...
<?php
if (isset($_POST['branch'])) {
$_SESSION['branch'] = $_POST['branch'];
}
?>
or supply it as a hidden element in the form ...
<?php
echo <<
END_INPUT;
?>
sort of thing.
Now, if you take out the exit in the code, what do you get when you press submit on the SearchPage page?
The right answer still?
But it all goes horribly wrong when you choose one of the buttons?
The reason is that nothing is remembered.
The passing of "branch" was not remembered.
Either put the branch in the session ...
<?php
if (isset($_POST['branch'])) {
$_SESSION['branch'] = $_POST['branch'];
}
?>
or supply it as a hidden element in the form ...
<?php
echo <<
END_INPUT;
?>
sort of thing.
ASKER
Hi
I am really struggling with this
I am really struggling with this
ASKER
Hi RQuadling
<?php
if (isset($_POST['branch'])) {
$_SESSION['branch'] = $_POST['branch'];
}
?>
or supply it as a hidden element in the form ...
<?php
echo <<<END_INPUT
<input type="hidden" name="branch" value="{$_POST['branch']}" />
END_INPUT;
?>
Which I did and still using
<input type="hidden" name="branch" value="{$_POST['branch']}" />
I even tried
<input type="hidden" name="id" value="<?php echo "'".$row['AssetID']."'" ?>" />
I get the following error
<?php
if (isset($_POST['branch'])) {
$_SESSION['branch'] = $_POST['branch'];
}
?>
or supply it as a hidden element in the form ...
<?php
echo <<<END_INPUT
<input type="hidden" name="branch" value="{$_POST['branch']}"
END_INPUT;
?>
Which I did and still using
<input type="hidden" name="branch" value="{$_POST['branch']}"
I even tried
<input type="hidden" name="id" value="<?php echo "'".$row['AssetID']."'" ?>" />
I get the following error
$_COOKIE = array (
'PHPSESSID' => '0b382de4d65c1565f79cfc19e104dcef',
)
$_GET = array (
'changeCheck' => '19',
'post_page' => 'page_3',
'branch' => '{$_POST[\\\'branch\\\']}',
)
$_POST = array (
)
$_SESSION = array (
'cost_code' => 'NTOP10IT06',
)
Home Whats New Search Add Asset
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
ASKER
Hi RQuadling
I have tried this and received Error message
<input type="hidden" name="id" value='".$row['AssetID']." ' />
I have tried this and received Error message
<input type="hidden" name="id" value='".$row['AssetID']."
$_COOKIE = array (
'PHPSESSID' => '3b8091c6be0ff97a51a6253862592b5f',
)
$_GET = array (
'changeCheck' => '19',
'post_page' => 'page_4',
'id' => '\\".$row[',
)
$_POST = array (
)
$_SESSION = array (
'cost_code' => 'NTOP10IT06',
)
Home Whats New Search Add Asset
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
'branch' => '{$_POST[\\\'branch\\\']}' ,
You notice your mistake?
Instead of assigning the VALUE of $_POST['branch'], you've assigned the string "$_POST['branch']".
Always look at the HTML that is generated in the browser (view source by right clicking on the page normally).
Hopefully, this will explain what is going on ...
1 - In the form that is on SearchPage.php, the variable $_POST['branch'] is supplied to search.php. This is supplied ONLY to search.php. Without you doing some extra work (coming to that) it is not remembered beyond that 1 request.
2 - Whilst you show the results in search.php, $_POST['branch'] is available to you. If you want to pass the value onto other pages, the HTML output you generate will have to have the value within it in some way.
There are 3 ways I can think of ...
1 - Add it as a hidden <input>
2 - Add it to any URLs that may need it.
3 - Add it to the session.
1 - This requires the <form> (if there is one) to have the hidden input tag.
<input type="hidden" name="branch" value="{$_POST['branch'}" />
So, this is saying that THIS form has a variable called branch with the value of the contents of $_POST['branch'], which, at this stage, we know to have come from the previous page.
2 - In the form's action (if there is one), you can say ...
action="newpage.php?branch ={$_POST[' branch']}"
sort of thing. This is fine in some instances, but if the newpage.php script is expecting branch to be POST'd, then this will not work as URL params are GET'd.
3 - On the start of every page, you need to create the session (or connect to an existing one) by the use of ...
session_start();
In search.php, you can store the branch in the session.
$_SESSION['branch'] = $_POST['branch']
This is the only time you need to store the branch (supplied by the user using searchpage.php to search.php).
From that point on, $_SESSION['branch'] will be remembered from page to page as long as you attach to the session using ...
session_start();
If you intend to re-use the same script which did the initial assignment to the session, you have to remember that $_POST['branch'] is only available on the FIRST call from searchpage.php to search.php.
So, you have to not override the session stored branch when it has not been supplied...
if (isset($_POST['branch'])) {
$_SESSION['branch'] = $_POST['branch'];
}
I really hope this makes sense.
You notice your mistake?
Instead of assigning the VALUE of $_POST['branch'], you've assigned the string "$_POST['branch']".
Always look at the HTML that is generated in the browser (view source by right clicking on the page normally).
Hopefully, this will explain what is going on ...
1 - In the form that is on SearchPage.php, the variable $_POST['branch'] is supplied to search.php. This is supplied ONLY to search.php. Without you doing some extra work (coming to that) it is not remembered beyond that 1 request.
2 - Whilst you show the results in search.php, $_POST['branch'] is available to you. If you want to pass the value onto other pages, the HTML output you generate will have to have the value within it in some way.
There are 3 ways I can think of ...
1 - Add it as a hidden <input>
2 - Add it to any URLs that may need it.
3 - Add it to the session.
1 - This requires the <form> (if there is one) to have the hidden input tag.
<input type="hidden" name="branch" value="{$_POST['branch'}" />
So, this is saying that THIS form has a variable called branch with the value of the contents of $_POST['branch'], which, at this stage, we know to have come from the previous page.
2 - In the form's action (if there is one), you can say ...
action="newpage.php?branch
sort of thing. This is fine in some instances, but if the newpage.php script is expecting branch to be POST'd, then this will not work as URL params are GET'd.
3 - On the start of every page, you need to create the session (or connect to an existing one) by the use of ...
session_start();
In search.php, you can store the branch in the session.
$_SESSION['branch'] = $_POST['branch']
This is the only time you need to store the branch (supplied by the user using searchpage.php to search.php).
From that point on, $_SESSION['branch'] will be remembered from page to page as long as you attach to the session using ...
session_start();
If you intend to re-use the same script which did the initial assignment to the session, you have to remember that $_POST['branch'] is only available on the FIRST call from searchpage.php to search.php.
So, you have to not override the session stored branch when it has not been supplied...
if (isset($_POST['branch'])) {
$_SESSION['branch'] = $_POST['branch'];
}
I really hope this makes sense.
ASKER
Hi
I have manage to work around this and I get to the next page, but if possible can you show me how to add the id in the url so that I can verify that the correct id is being updated.
This is how my form looks
<form action="../">
<select onchange="window.open(this .options[t his.select edIndex].v alue,'_top ')">
<option value="">Choose a Action</option>
<option value="asset_move.php">Reg ister a Transfer</option>
<option value="place_into_storage. php">Place into storage</option>
<option value="register_as_broken. php">Regis ter as Broken</option>
<option value="decommission.php">D ecommissio n</option>
</select>
</form>
I have manage to work around this and I get to the next page, but if possible can you show me how to add the id in the url so that I can verify that the correct id is being updated.
This is how my form looks
<form action="../">
<select onchange="window.open(this
<option value="">Choose a Action</option>
<option value="asset_move.php">Reg
<option value="place_into_storage.
<option value="register_as_broken.
<option value="decommission.php">D
</select>
</form>
<?php
session_start();
?>
<?php include "Menu.php"; ?>
<html>
<?php
define("DB_HOST","servername");
define("DB_USER","username");
define("DB_PASS","password");
define("DB_NAME","database");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
$cost_code = $_POST['branch'];
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= '$cost_code'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query".mssql_get_last_message());
if(mssql_num_rows($result) == 0) exit("Cost code not found:<br>$query<br>Cost code var:$cost_code");
$_SESSION['cost_code'] = $_POST['branch'];
$row = mssql_fetch_assoc($result);
$get_assets = "SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = ".$row['BranchID']."";
$get_assets_result = mssql_query($get_assets, $db_connection);
if(!$get_assets_result) exit("Could not execute query:<br>$get_assets<br>".mssql_get_last_message());
if(mssql_num_rows($get_assets_result) == 0) exit("No assets found for branch");
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";
?>
<form action="../">
<select onchange="window.open(this.options[this.selectedIndex].value,'_top')">
<option value="">Choose a Action</option>
<option value="asset_move.php">Register a Transfer</option>
<option value="place_into_storage.php">Place into storage</option>
<option value="register_as_broken.php">Register as Broken</option>
<option value="decommission.php">Decommission</option>
</select>
</form>
</body>
</html>
Take a look at the actual output of that script.
Again, you have <input> tags OUTSIDE of the <form></form> tag.
They have to be within the <form> tag to be picked up when the form is submitted.
HTML is hierarchial in nature (just like all XML style documents).
<container1>
<container2>
<container3>
<element1 />
<element2 />
</container3>
</container2>
</container1>
So, elements are inside containers.
Your code is more like ...
<container1>
<container2>
<container3>
</container3>
</container2>
</container1>
<element1 />
<element2 />
The elements are not contained.
Adding the param to the action URL ...
<form action="pagename.php?name= value" method="post">
I wouldn't recommend using this in this instance as you now have 2 different sources of the same variable and no way of knowing which is which.
Remember, the web server doesn't remember what the previous request is. Web pages are normally stateless. The idea of a sequence of pages is not how things work. We fake state by using sessions (that's one of the most popular ways).
Remember what ever PHP code you right, it is the HTML output that has to be right. So always check that.
Use FireFox with the HTML Validation extension and it will give you a nice list of all the errors.
Again, you have <input> tags OUTSIDE of the <form></form> tag.
They have to be within the <form> tag to be picked up when the form is submitted.
HTML is hierarchial in nature (just like all XML style documents).
<container1>
<container2>
<container3>
<element1 />
<element2 />
</container3>
</container2>
</container1>
So, elements are inside containers.
Your code is more like ...
<container1>
<container2>
<container3>
</container3>
</container2>
</container1>
<element1 />
<element2 />
The elements are not contained.
Adding the param to the action URL ...
<form action="pagename.php?name=
I wouldn't recommend using this in this instance as you now have 2 different sources of the same variable and no way of knowing which is which.
Remember, the web server doesn't remember what the previous request is. Web pages are normally stateless. The idea of a sequence of pages is not how things work. We fake state by using sessions (that's one of the most popular ways).
Remember what ever PHP code you right, it is the HTML output that has to be right. So always check that.
Use FireFox with the HTML Validation extension and it will give you a nice list of all the errors.
ASKER
Hi
I am not sure by what you mean here
when I go to the next page i need my page my url should look like this
http://usvddev/Assetmanagement/asset_move.php?id=20
I am not sure by what you mean here
when I go to the next page i need my page my url should look like this
http://usvddev/Assetmanagement/asset_move.php?id=20
To have the parameters automatically added to the URL, which are generated by the form elements, then you need to method="GET", but this will give ALL of the parameters.
And then the PHP code will need to use $_GET['.....']
ASKER
Hi
I have used this
<input type="hidden" name="changeCheck" value="<?php echo $_GET['changeCheck']; ?>" />
But the id is not displayin gin the URL
I have used this
<input type="hidden" name="changeCheck" value="<?php echo $_GET['changeCheck']; ?>" />
But the id is not displayin gin the URL
<form action="../">
<input type="hidden" name="changeCheck" value="<?php echo $_GET['changeCheck']; ?>" />
<select onchange="window.open(this.options[this.selectedIndex].value,'_top')">
<option value="">Choose a Action</option>
<option value="asset_move.php">Register a Transfer</option>
<option value="place_into_storage.php">Place into storage</option>
<option value="register_as_broken.php">Register as Broken</option>
<option value="decommission.php">Decommission</option>
</select>
</form>
ASKER
Hi
I have used the
<input type="hidden" name="changeCheck" value="<?php echo $_GET['changeCheck']; ?>" />
because I used this in my T^able that will display the data
I have used the
<input type="hidden" name="changeCheck" value="<?php echo $_GET['changeCheck']; ?>" />
because I used this in my T^able that will display the data
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";
?>
I think I've missed something which I'm taking for granted.
PLEASE PLEASE PLEASE, look at the HTML output.
PLEASE use FireFox with the HTML Validation extension and then validate your HTML.
I'm running in circles and repeating myself. I can offer nothing more other than to do the work for you, and really that's not what I'm about.
The HTML output is going to show you that the <form> tag is in the wrong place.
A live site for me to see your output would be significantly beneficial.
PLEASE PLEASE PLEASE, look at the HTML output.
PLEASE use FireFox with the HTML Validation extension and then validate your HTML.
I'm running in circles and repeating myself. I can offer nothing more other than to do the work for you, and really that's not what I'm about.
The HTML output is going to show you that the <form> tag is in the wrong place.
A live site for me to see your output would be significantly beneficial.
ASKER
Hi
I did not use fire fox and installed it and found on errors on my search.php page. I have now corrected it. Can I now get my ID in the URL ?
Sorry for not looking into this closer :-(
I did not use fire fox and installed it and found on errors on my search.php page. I have now corrected it. Can I now get my ID in the URL ?
Sorry for not looking into this closer :-(
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Search Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
define("DB_HOST","localhost");
define("DB_USER","ServiceDesk");
define("DB_PASS","ServiceDesk");
define("DB_NAME","AssetDB");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
$cost_code = $_POST['branch'];
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= '$cost_code'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query".mssql_get_last_message());
if(mssql_num_rows($result) == 0) exit("Cost code not found:<br>$query<br>Cost code var:$cost_code");
$_SESSION['cost_code'] = $_POST['branch'];
$row = mssql_fetch_assoc($result);
$get_assets = "SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = ".$row['BranchID']."";
$get_assets_result = mssql_query($get_assets, $db_connection);
if(!$get_assets_result) exit("Could not execute query:<br>$get_assets<br>".mssql_get_last_message());
if(mssql_num_rows($get_assets_result) == 0) exit("No assets found for branch");
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";
?>
<form action="../">
<input type="hidden" name="changeCheck" value="<?php echo $_POST['changeCheck']; ?>" />
<select onchange="window.open(this.options[this.selectedIndex].value,'_top')">
<option value="">Choose a Action</option>
<option value="asset_move.php">Register a Transfer</option>
<option value="place_into_storage.php">Place into storage</option>
<option value="register_as_broken.php">Register as Broken</option>
<option value="decommission.php">Decommission</option>
</select>
</form>
</body>
</html>
ASKER
Hi RQuadling
I have looked opne all my pages in firefix are got a lot on errors which I have corrected. Can you assist me now with the ID in the URL field.
Thanks
I have looked opne all my pages in firefix are got a lot on errors which I have corrected. Can you assist me now with the ID in the URL field.
Thanks
ASKER
Hi
I have added but in my url I get
http://usvddev/AssetManagement/asset_move.php?id=
I just need the valie displayed ?
I have added but in my url I get
http://usvddev/AssetManagement/asset_move.php?id=
I just need the valie displayed ?
<form action="../">
<select onchange="window.open(this.options[this.selectedIndex].value,'_top')">
<option value="">Choose a Action</option>
<option value="asset_move.php?id=".$row['AssetID']."'">Register a Transfer</option>
<option value="place_into_storage.php?id=".$row['AssetID']."'">Place into storage</option>
<option value="register_as_broken.php?id=".$row['AssetID']."'">Register as Broken</option>
<option value="decommission.php?id=".$row['AssetID']."'">Decommission</option>
</select>
</form>
ASKER
Hi RQuadling
Any updates yet ?
Any updates yet ?
ASKER
Hi
(Firstly I have corredted by Error in Fire Fix in the searc.php page)
I have made changes to the code by inputing this. But I am still getting the error
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
(Firstly I have corredted by Error in Fire Fix in the searc.php page)
I have made changes to the code by inputing this. But I am still getting the error
Cost code not found:
SELECT BranchID FROM Branch WHERE branchcostcode= ''
Cost code var:
<?php
if(isset($_POST['submit'])) {
header("Location: ".$_POST['page']."?id=".$_POST['changeCheck']);
}
?>
<?php
if(isset($_POST["submit_action"])){
switch ($_POST["submit_action"]) {
case "Register a Transfer": header("Location: asset_move.php"); break;
case "Place into storage": header("Location: place_into_storage.php"); break;
case "Register as Broken": header("Location: register_as_broken.php"); break;
case "Decommission": header("Location: decommission.php"); break;
}
}
?>
<form action="" method="post">
<input type="submit" value="Register a Transfer" name="submit_action" />
<input type="submit" value="Place into storage" name="submit_action"/>
<input type="submit" value="Register as Broken" name="submit_action"/>
<input type="submit" value="Decommission" name="submit_action"/>
<input type="hidden" name="changeCheck" value="<?php echo $_POST['changeCheck']; ?>" />
</form>
ASKER
Hi
Just to clarify I have added the whole search.php code. Now I do not knwo what I am doing wrong because nothing changes just the button and now I am getting the Error
Just to clarify I have added the whole search.php code. Now I do not knwo what I am doing wrong because nothing changes just the button and now I am getting the Error
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Search Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php include "Menu.php"; ?>
<?php
define("DB_HOST","servername");
define("DB_USER","username");
define("DB_PASS","password");
define("DB_NAME","database");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
$cost_code = $_POST['branch'];
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= '$cost_code'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query".mssql_get_last_message());
if(mssql_num_rows($result) == 0) exit("Cost code not found:<br>$query<br>Cost code var:$cost_code");
$_SESSION['cost_code'] = $_POST['branch'];
$row = mssql_fetch_assoc($result);
$get_assets = "SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = ".$row['BranchID']."";
$get_assets_result = mssql_query($get_assets, $db_connection);
if(!$get_assets_result) exit("Could not execute query:<br>$get_assets<br>".mssql_get_last_message());
if(mssql_num_rows($get_assets_result) == 0) exit("No assets found for branch");
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";
?>
<?php
if(isset($_POST['submit'])) {
header("Location: ".$_POST['page']."?id=".$_POST['changeCheck']);
}
?>
<?php
if(isset($_POST["submit_action"])){
switch ($_POST["submit_action"]) {
case "Register a Transfer": header("Location: asset_move.php"); break;
case "Place into storage": header("Location: place_into_storage.php"); break;
case "Register as Broken": header("Location: register_as_broken.php"); break;
case "Decommission": header("Location: decommission.php"); break;
}
}
?>
<form action="" method="post">
<input type="submit" value="Register a Transfer" name="submit_action" />
<input type="submit" value="Place into storage" name="submit_action"/>
<input type="submit" value="Register as Broken" name="submit_action"/>
<input type="submit" value="Decommission" name="submit_action"/>
<input type="hidden" name="changeCheck" value="<?php echo $_POST['changeCheck']; ?>" />
</form>
</body>
</html>
ASKER
I will have to do this with javascrip
Give me a public URL to the code and I can help you.
It seems that there is some really basic principles that I'm not able to explain very clearly.
Using FireFox with FireBug you can monitor your client side Javascript code.
Using PHP and command like print_r(...), var_dump(....), you can monitor your PHP code.
Just because the HTML, JS and PHP all exist in the same file, doesn't mean they all run at the same time.
The PHP codes runs on the server and produces a "result". This is sent to the browser. The "result" is a combination of HTML and JS in this instance. Making a change to the form, doesn't execute the PHP code. That only happens when the page is sent.
Can you upload the files you are using. Don't put them in the code snippet. But as file uploads.
That way I can see the names of the files you are using.
It seems that there is some really basic principles that I'm not able to explain very clearly.
Using FireFox with FireBug you can monitor your client side Javascript code.
Using PHP and command like print_r(...), var_dump(....), you can monitor your PHP code.
Just because the HTML, JS and PHP all exist in the same file, doesn't mean they all run at the same time.
The PHP codes runs on the server and produces a "result". This is sent to the browser. The "result" is a combination of HTML and JS in this instance. Making a change to the form, doesn't execute the PHP code. That only happens when the page is sent.
Can you upload the files you are using. Don't put them in the code snippet. But as file uploads.
That way I can see the names of the files you are using.
ASKER
Hi
http://10.30.133.6/AssetManagement/SearchPage.php
use cost code NTOP10IT06 to test
I have change my form again with a onclick and it goes ot the next page but does nto display the ID in the url
http://10.30.133.6/AssetManagement/asset_move.php?changeCheck=
http://10.30.133.6/AssetManagement/SearchPage.php
use cost code NTOP10IT06 to test
I have change my form again with a onclick and it goes ot the next page but does nto display the ID in the url
http://10.30.133.6/AssetManagement/asset_move.php?changeCheck=
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Search Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php include "Menu.php"; ?>
<?php
define("DB_HOST","localhost");
define("DB_USER","ServiceDesk");
define("DB_PASS","ServiceDesk");
define("DB_NAME","AssetDB");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
$cost_code = $_POST['branch'];
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= '$cost_code'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0) exit("Cost code not found:<br>$query<br>Cost code var:$cost_code");
$_SESSION['cost_code'] = $_POST['branch'];
$row = mssql_fetch_assoc($result);
$get_assets = "SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = ".$row['BranchID']."";
$get_assets_result = mssql_query($get_assets, $db_connection);
if(!$get_assets_result) exit("Could not execute query:<br>$get_assets<br>".mssql_get_last_message());
if(mssql_num_rows($get_assets_result) == 0) exit("No assets found for branch");
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";
?>
<?php
if(isset($_POST['submit'])) {
header("Location: ".$_POST['page']."?id=".$_POST['changeCheck']);
}
?>
<form action="">
<input type="submit" value="Register a Transfer" onclick="this.form.action='asset_move.php';"/>
<input type="submit" value="Place into storage" onclick="this.form.action='place_into_storage.php';"/>
<input type="submit" value="Register as Broken" onclick="this.form.action='register_as_broken.php'" />
<input type="submit" value="Decommission" onclick="this.form.action='decommission.php';" />
<input type="hidden" name="changeCheck" value="<?php echo $_POST['changeCheck']; ?>" />
</form>
</body>
</html>
10.x.x.x is private to your network. See http://en.wikipedia.org/wiki/Private_network
Try this.
Move line 108 to before line 10.
Try this.
Move line 108 to before line 10.
If that is your machine name, it is not on the internet ...
2008/08/21 9:50:33 C:\>ping usvddev
Ping request could not find host usvddev. Please check the name and try again.
2008/08/21 9:50:33 C:\>ping usvddev
Ping request could not find host usvddev. Please check the name and try again.
ASKER
Hi
I have just confirmed that you will not be able to connect ?
I have just confirmed that you will not be able to connect ?
ASKER
Hi
Can youi assist me like this ? Using the code below. I get the next page just the ID dusplaying in the URL
Can youi assist me like this ? Using the code below. I get the next page just the ID dusplaying in the URL
<?php
if(isset($_POST['submit'])) {
header("Location: ".$_POST['page']."?id=".$_POST['changeCheck']);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Search Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php include "Menu.php"; ?>
<?php
define("DB_HOST","servername");
define("DB_USER","username");
define("DB_PASS","password");
define("DB_NAME","database");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
$cost_code = $_POST['branch'];
$query = "SELECT BranchID FROM Branch WHERE branchcostcode= '$cost_code'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0) exit("Cost code not found:<br>$query<br>Cost code var:$cost_code");
$_SESSION['cost_code'] = $_POST['branch'];
$row = mssql_fetch_assoc($result);
$get_assets = "SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = ".$row['BranchID']."";
$get_assets_result = mssql_query($get_assets, $db_connection);
if(!$get_assets_result) exit("Could not execute query:<br>$get_assets<br>".mssql_get_last_message());
if(mssql_num_rows($get_assets_result) == 0) exit("No assets found for branch");
echo "<table border=\"2\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>Select</th>";
echo "<th>DeviceType</th>";
echo "<th>DeviceMake</th>";
echo "<th>DeviceModel</th>";
echo "<th>Serial</th>";
echo "<th>Cost Code</th>";
echo "<th>Domain User</th>";
echo "<th>Date Modified</th>";
echo "<th>Date Created</th>";
echo "<th>Status</th>";
echo "<th>Change Order</th>";
echo "</tr>";
while($row = mssql_fetch_assoc($get_assets_result))
{
$asset_details = " select
c.TypeName,
d.MakeName,
e.ModelName,
a.AssetSerial,
DomainUser,
convert(varchar,a.Datemodified,111) As DateModified,
convert(varchar,a.DateCreated,111) As DateCreated,
b.Statusname,
a.AssetID,
g.branchcostcode,
g.changeorder
from
dbo.Asset a left join dbo.Status b
ON a.statusid = b.statusid
left join dbo.AssetType c
ON c.typeid = a.typeid
left join dbo.AssetMake d
on d.makeid = a.makeid
left join dbo.MakeModel e
on e.modelid = a.modelid
left join Asset_branch_link f
on f.assetid = a.assetid
left join branch g
on g.branchid = f.branchid
WHERE a.AssetID = '".$row['AssetID']."'";
$asset_details_result = mssql_query($asset_details, $db_connection);
if(!$asset_details_result) exit("Could not execute query:<br>$asset_details<br>".mssql_get_last_message());
if(mssql_num_rows($asset_details_result) == 0) exit("Could not find asset ".$row['Asset_id']." in Assets table:<br>$asset_details<br>".mssql_get_last_message());
$row = mssql_fetch_assoc($asset_details_result);
echo "<tr>";
echo "<td><input name='changeCheck' type='radio' value='".$row['AssetID']."'/></td>";
echo "<td>".$row['TypeName']."</td>";
echo "<td>".$row['MakeName']."</td>";
echo "<td>".$row['ModelName']."</td>";
echo "<td>".$row['AssetSerial']."</td>";
echo "<td>".$row['branchcostcode']."</td>";
echo "<td>".$row['DomainUser']."</td>";
echo "<td>".$row['DateModified']."</td>";
echo "<td>".$row['DateCreated']."</td>";
echo "<td>".$row['Statusname']."</td>";
echo "<td>".$row['changeorder']."</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";
?>
<form method="post" action="page">
<input type="submit" value="Register a Transfer" onclick="this.form.action='asset_move.php';"/>
<input type="submit" value="Place into storage" onclick="this.form.action='place_into_storage.php';"/>
<input type="submit" value="Register as Broken" onclick="this.form.action='register_as_broken.php'" />
<input type="submit" value="Decommission" onclick="this.form.action='decommission.php';" />
<input type="hidden" name="changeCheck" value="<?php echo $_POST['changeCheck']; ?>" />
</form>
</body>
</html>
ASKER
Hi RQuadling
Are you still there?
I tried something else. I made sure that my values are displayed in the table date. See code. But my hidden value does not display or gets populated.
<?php
if(isset($_POST['submit']) ) {
header("Location: ".$_POST['page']."?id=".$_ POST['chan geCheck']) ;
}
?>
<form action="page" method="post">
<input type="submit" value="Register a Transfer" onclick="this.form.action= 'asset_mov e.php';"/>
<input type="submit" value="Place into storage" onclick="this.form.action= 'place_int o_storage. php';"/>
<input type="submit" value="Register as Broken" onclick="this.form.action= 'register_ as_broken. php'" />
<input type="submit" value="Decommission" onclick="this.form.action= 'decommiss ion.php';" />
<input type="hidden" value="<?php echo $_GET['changeCheck']; ?>" name="changeCheck" />
</form>
<?php
Are you still there?
I tried something else. I made sure that my values are displayed in the table date. See code. But my hidden value does not display or gets populated.
<?php
if(isset($_POST['submit'])
header("Location: ".$_POST['page']."?id=".$_
}
?>
<form action="page" method="post">
<input type="submit" value="Register a Transfer" onclick="this.form.action=
<input type="submit" value="Place into storage" onclick="this.form.action=
<input type="submit" value="Register as Broken" onclick="this.form.action=
<input type="submit" value="Decommission" onclick="this.form.action=
<input type="hidden" value="<?php echo $_GET['changeCheck']; ?>" name="changeCheck" />
</form>
<?php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Search Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table>
<tr>
<td><a href="HomePage.php">Home</a></td>
<td><a href="WhatsNew.php">Whats New</a></td>
<!--<td><a href="Download.php">Download</a></td>-->
<td><a href="SearchPage.php">Search</a></td>
<td><a href="create_asset.php">Add Asset</a></td>
</tr>
</table><br>
<table border="2" cellspacing="1"><tr><th>Select</th><th>DeviceType</th><th>DeviceMake</th><th>DeviceModel</th><th>Serial</th><th>Cost Code</th><th>Domain User</th><th>Date Modified</th><th>Date Created</th><th>Status</th><th>Change Order</th></tr><tr><td><input name='changeCheck' type='radio' value='17'/></td><td>Desktop</td><td>HP Compaq</td><td>Deskpro EN</td><td>PTDXCVB345678</td><td>NTOP10IT06</td><td>Anthonio</td><td>2008/07/09</td><td>2008/07/09</td><td>Registered</td><td>CO08353</td></tr><tr><td><input name='changeCheck' type='radio' value='18'/></td><td>Desktop</td><td>HP Compaq</td><td>Deskpro EN</td><td>PTDXCVB345678</td><td>NTOP10IT06</td><td>Anthonio</td><td>2008/07/09</td><td>2008/07/09</td><td>Registered</td><td>CO08353</td></tr><tr><td><input name='changeCheck' type='radio' value='19'/></td><td>Desktop</td><td>HP Compaq</td><td>Deskpro EN</td><td>PTDXCVB345678</td><td>NTOP10IT06</td><td>Anthonio</td><td>2008/07/09</td><td>2008/07/09</td><td>Registered</td><td>CO08353</td></tr><tr><td><input name='changeCheck' type='radio' value='20'/></td><td>Desktop</td><td>HP Compaq</td><td>Deskpro EN</td><td>PTDXCVB345678</td><td>NTOP10IT06</td><td>Anthonio</td><td>2008/07/09</td><td>2008/07/09</td><td>Registered</td><td>CO08353</td></tr><tr><td><input name='changeCheck' type='radio' value='21'/></td><td>Desktop</td><td>HP Compaq</td><td>Deskpro EN</td><td>PTRSXCVBNM</td><td>NTOP10IT06</td><td>BOOYSEN</td><td>2008/07/09</td><td>2008/07/09</td><td>Registered</td><td>CO08353</td></tr></table><br>
<form method="post" action="page">
<input type="submit" value="Register a Transfer" onclick="this.form.action='asset_move.php';"/>
<input type="submit" value="Place into storage" onclick="this.form.action='place_into_storage.php';"/>
<input type="submit" value="Register as Broken" onclick="this.form.action='register_as_broken.php'" />
<input type="submit" value="Decommission" onclick="this.form.action='decommission.php';" />
<input type="hidden" value="" name="changeCheck" />
</form>
$_GET = Array
(
)
$_POST = Array
(
[branch] => NTOP10IT06
)
</body>
</html>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
I have changed and the ID value does nto appear in the URL.
http://usvddev/AssetManagement/asset_move.php?changeCheck=
If I go to the next page (asset_move.php) the value appears a blank source code
<input type="hidden" value="" name="id">
I have changed and the ID value does nto appear in the URL.
http://usvddev/AssetManagement/asset_move.php?changeCheck=
If I go to the next page (asset_move.php) the value appears a blank source code
<input type="hidden" value="" name="id">
<?php
if(isset($_POST['submit'])) {
header("Location: ".$_POST['page']."?changeCheck=".$_POST['changeCheck']);
}
?>
<form action="page">
<input type="submit" value="Register a Transfer" onclick="this.form.action='asset_move.php';"/>
<input type="submit" value="Place into storage" onclick="this.form.action='place_into_storage.php';"/>
<input type="submit" value="Register as Broken" onclick="this.form.action='register_as_broken.php';" />
<input type="submit" value="Decommission" onclick="this.form.action='decommission.php';" />
<input type="hidden" value="<?php echo $_GET['changeCheck']; ?>" name="changeCheck" />
</form>
You've removed the method of the form. Make sure it is set appropriately.
I'm very confused now. I don't know where the data is coming from.
I need all the forms involved and the PHP code involved.
Without it, I can't follow what you are doing. The code has changed so much since the start of this question that I can't see what I'm doing.
Sorry.
I'm very confused now. I don't know where the data is coming from.
I need all the forms involved and the PHP code involved.
Without it, I can't follow what you are doing. The code has changed so much since the start of this question that I can't see what I'm doing.
Sorry.
ASKER
Hi
I will attached the php file involved.
Ther user will have to enter a branch cost code to get all Asset link to the cost code. The will then display on the search.php. Result will then be displayed in the search.php page with radio button selections. All the radions selection have a different AssetID.
file-2.zip
I will attached the php file involved.
Ther user will have to enter a branch cost code to get all Asset link to the cost code. The will then display on the search.php. Result will then be displayed in the search.php page with radio button selections. All the radions selection have a different AssetID.
file-2.zip
ASKER
Attached is the first file
file.zip
file.zip
ASKER
The this file is attached
file-3.zip
file-3.zip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Richard
I have change the code and when searhcing the Error appears
Could not find asset in Assets table:
select c.TypeName, d.MakeName, e.ModelName, a.AssetSerial, DomainUser, convert(varchar,a.Datemodi fied,111) As DateModified, convert(varchar,a.DateCrea ted,111) As DateCreated, b.Statusname, a.AssetID, g.branchcostcode, g.changeorder from dbo.Asset a left join dbo.Status b ON a.statusid = b.statusid left join dbo.AssetType c ON c.typeid = a.typeid left join dbo.AssetMake d on d.makeid = a.makeid left join dbo.MakeModel e on e.modelid = a.modelid left join Asset_branch_link f on f.assetid = a.assetid left join branch g on g.branchid = f.branchid WHERE a.AssetID = ''
Also I see that my branchcost code appreas in the URL wonderfull.
http://usvddev/AssetManagement/search.php?branch=NTOP10IT06
Question can I let my ID appreas in the URL
I have change the code and when searhcing the Error appears
Could not find asset in Assets table:
select c.TypeName, d.MakeName, e.ModelName, a.AssetSerial, DomainUser, convert(varchar,a.Datemodi
Also I see that my branchcost code appreas in the URL wonderfull.
http://usvddev/AssetManagement/search.php?branch=NTOP10IT06
Question can I let my ID appreas in the URL
ASKER
Hi
Question can I let my ID appreas in the URL. This would be the AssetID in
select AssetID,* from Asset
Question can I let my ID appreas in the URL. This would be the AssetID in
select AssetID,* from Asset
Ok. It seems as if I'm doing the job for you <grin style="wry" />.
Add some debugging to the code so you know what is being received ...
print_r($_GET);
print_r($_POST);
print_r($_SESSION);
This should be within the main body of the page (so after the menu include).
For each SQL statement, echo the SQL statement before you execute it. So you know now what is being asked of by the DB.
Add some debugging to the code so you know what is being received ...
print_r($_GET);
print_r($_POST);
print_r($_SESSION);
This should be within the main body of the page (so after the menu include).
For each SQL statement, echo the SQL statement before you execute it. So you know now what is being asked of by the DB.
ASKER
Hi
Be nice RQuadling :-)
Array ( [branch] => NTOP10IT06 ) Array ( ) Array ( [branch] => NTOP10IT06 )
I think the reason for this is because I do not get the AssetID from my database.
Be nice RQuadling :-)
Array ( [branch] => NTOP10IT06 ) Array ( ) Array ( [branch] => NTOP10IT06 )
I think the reason for this is because I do not get the AssetID from my database.
ASKER
Array ( [branch] => NTOP10IT06 ) Array ( ) Array ( [branch] => NTOP10IT06 )
SELECT BranchID FROM Branch WHERE branchcostcode= 'NTOP10IT06'
SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = 1
Could not find asset in Assets table:
select c.TypeName, d.MakeName, e.ModelName, a.AssetSerial, DomainUser, convert(varchar,a.Datemodi fied,111) As DateModified, convert(varchar,a.DateCrea ted,111) As DateCreated, b.Statusname, a.AssetID, g.branchcostcode, g.changeorder from dbo.Asset a left join dbo.Status b ON a.statusid = b.statusid left join dbo.AssetType c ON c.typeid = a.typeid left join dbo.AssetMake d on d.makeid = a.makeid left join dbo.MakeModel e on e.modelid = a.modelid left join Asset_branch_link f on f.assetid = a.assetid left join branch g on g.branchid = f.branchid WHERE a.AssetID = ''
SELECT BranchID FROM Branch WHERE branchcostcode= 'NTOP10IT06'
SELECT AssetID FROM Asset_Branch_Link WHERE BranchID = 1
Could not find asset in Assets table:
select c.TypeName, d.MakeName, e.ModelName, a.AssetSerial, DomainUser, convert(varchar,a.Datemodi
ASKER
Hi
I have changed it
from
while(False !== ($row = mssql_fetch_assoc($get_ass ets_result )))
to
while(False !== ($a_Branch = mssql_fetch_assoc($get_ass ets_result )))
and I can see my ID
I have changed it
from
while(False !== ($row = mssql_fetch_assoc($get_ass
to
while(False !== ($a_Branch = mssql_fetch_assoc($get_ass
and I can see my ID
Ah. Yes. I mentioned that didn't I! Sorry for not spotting it.
The way the HTML and the PHP code is all mixed up makes it harder for me to work things out.
But.
Have you got it all working now?
Remember that you will need to amend all the action scripts to use the new way of getting the data (basically the session).
Sessions are really the best place to pass data around. They only ever need to be updated in 1 place and you can read them everywhere. No URLs to bypass the logic. Secure. etc.
The way the HTML and the PHP code is all mixed up makes it harder for me to work things out.
But.
Have you got it all working now?
Remember that you will need to amend all the action scripts to use the new way of getting the data (basically the session).
Sessions are really the best place to pass data around. They only ever need to be updated in 1 place and you can read them everywhere. No URLs to bypass the logic. Secure. etc.
ASKER
Hi
My data is not displaying in my form.table
My data is not displaying in my form.table
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Search Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table>
<tr>
<td><a href="HomePage.php">Home</a></td>
<td><a href="WhatsNew.php">Whats New</a></td>
<!--<td><a href="Download.php">Download</a></td>-->
<td><a href="SearchPage.php">Search</a></td>
<td><a href="create_asset.php">Add Asset</a></td>
</tr>
</table><br>
<form method="post" action="">
<table border="2" cellspacing="1">
<tr>
<th>Select</th>
<th>DeviceType</th>
<th>DeviceMake</th>
<th>DeviceModel</th>
<th>Serial</th>
<th>Cost Code</th>
<th>Domain User</th>
<th>Date Modified</th>
<th>Date Created</th>
<th>Status</th>
<th>Change Order</th>
</tr>
<tr>
<td><input name="assetID" type="radio" value="17" /></td>
<td></td>
<td></td
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr> <tr>
<td><input name="assetID" type="radio" value="18" /></td>
<td></td>
<td></td
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr> <tr>
<td><input name="assetID" type="radio" value="19" /></td>
<td></td>
<td></td
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr> <tr>
<td><input name="assetID" type="radio" value="20" /></td>
<td></td>
<td></td
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr> <tr>
<td><input name="assetID" type="radio" value="21" /></td>
<td></td>
<td></td
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr></table>
<br>
<input type="submit" value="Register a Transfer" onclick="this.form.action='asset_move.php';"/>
<input type="submit" value="Place into storage" onclick="this.form.action='place_into_storage.php';"/>
<input type="submit" value="Register as Broken" onclick="this.form.action='register_as_broken.php';" />
<input type="submit" value="Decommission" onclick="this.form.action='decommission.php';" />
</form>
</body>
</html>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi RQuadling
THis works 100%. Any advise before I close this call?
THis works 100%. Any advise before I close this call?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
I have never had sure excellent help in my life. The Expert could have given up, but he was very helpfull and understanding. He even give me advise which is good. RQuadling thank you very much for all you effort and help with this and for the advise( repeating myself now).
I wish you all the best and keep up the good work.
Thanks
Anthonio Booysen
I have never had sure excellent help in my life. The Expert could have given up, but he was very helpfull and understanding. He even give me advise which is good. RQuadling thank you very much for all you effort and help with this and for the advise( repeating myself now).
I wish you all the best and keep up the good work.
Thanks
Anthonio Booysen
Whilst I was answering this question, I kept in mind 2 things.
1 - When I started out as a software developer (over 20 years ago), I knew nothing. I asked more questions than I thought existed. And it was through the careful hand holding and the occasional being shouting at that I finally got it. My email sig reflects this by having "Standing on the shoulders of some VERY clever giants.". Without the help I got when I started, I wouldn't be able to help others.
2 - As a recent attendee of the Experts Exchange 2008 Core Conference (EE2K8CC), mentoring was one of the aspects that EE would like to foster amongst the experts and the askers and I think that I did some of that here.
So, I AM glad my comments and suggestions were useful.
Thank you for the points, but more importantly thank you for your grading comments.
Richard Quadling.
1 - When I started out as a software developer (over 20 years ago), I knew nothing. I asked more questions than I thought existed. And it was through the careful hand holding and the occasional being shouting at that I finally got it. My email sig reflects this by having "Standing on the shoulders of some VERY clever giants.". Without the help I got when I started, I wouldn't be able to help others.
2 - As a recent attendee of the Experts Exchange 2008 Core Conference (EE2K8CC), mentoring was one of the aspects that EE would like to foster amongst the experts and the askers and I think that I did some of that here.
So, I AM glad my comments and suggestions were useful.
Thank you for the points, but more importantly thank you for your grading comments.
Richard Quadling.
ASKER
hi
I have added the php code on all action *.pgp pages. Mt one page get the ID but the others does not
I have added the php code on all action *.pgp pages. Mt one page get the ID but the others does not
<?php
session_start();
// If we get to this page with no branch being known, then go straight to the SearchPage.
if (!isset($_POST['assetID']))
{
header('Location : http://' . $_SERVER['SERVER_NAME'] . '/SearchPage.php');
exit();
}
// If a branch has been requested then remember the branch
elseif (isset($_POST['assetID']))
{
$_SESSION['assetID'] = $_POST['assetID'];
}
Change the last snippet you used to this ...
This is debugging code to show what is going on.
The snippet below replaces the 15 lines you gave in your last comment.
This is debugging code to show what is going on.
The snippet below replaces the 15 lines you gave in your last comment.
<?php
session_start();
// DEBUG : Show what information we have been supplied or have available.
echo '<pre>';
foreach(array('GET', 'POST', 'SESSION', 'COOKIE', 'FILES') as $s_Array)
{
$s = "_$s_Array";
echo "<br /><br />$s<br />";
print_r($$s);
}
echo '</pre>';
// If we get to this page with no branch being known, then go straight to the SearchPage.
if (!isset($_POST['assetID']))
{
// DEBUG : Disable redirect.
// header('Location : http://' . $_SERVER['SERVER_NAME'] . '/SearchPage.php');
// DEBUG : Show that the redirect will happen.
echo "header('Location : http://' . $_SERVER['SERVER_NAME'] . '/SearchPage.php');";
exit();
}
// If a branch has been requested then remember the branch
elseif (isset($_POST['assetID']))
{
$_SESSION['assetID'] = $_POST['assetID'];
}
ASKER
Hi
Should I cpoy the code below to all action *.php pages ?
Should I cpoy the code below to all action *.php pages ?
<?php
session_start();
// DEBUG : Show what information we have been supplied or have available.
echo '<pre>';
foreach(array('GET', 'POST', 'SESSION', 'COOKIE', 'FILES') as $s_Array)
{
$s = "_$s_Array";
echo "<br /><br />$s<br />";
print_r($$s);
}
echo '</pre>';
// If we get to this page with no branch being known, then go straight to the SearchPage.
if (!isset($_POST['assetID']))
{
// DEBUG : Disable redirect.
// header('Location : http://' . $_SERVER['SERVER_NAME'] . '/SearchPage.php');
// DEBUG : Show that the redirect will happen.
echo "header('Location : http://' . $_SERVER['SERVER_NAME'] . '/SearchPage.php');";
exit();
}
// If a branch has been requested then remember the branch
elseif (isset($_POST['assetID']))
{
$_SESSION['assetID'] = $_POST['assetID'];
}
ASKER
When I included this in all my action php pages I got the Error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Inetpub\wwwroot\AssetMa nagement\a sset_move. php on line 20
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
Sorry.
Replace the line 20 with ...
echo "header('Location : http://' . {$_SERVER['SERVER_NAME']} . '/SearchPage.php');";
Added {} around the $_SERVER['SERVER_NAME'] variable.
The code in the snippet is debugging code. I would expect you to put it in the action scripts as they are the ones you say you are having a problem with.
Replace the line 20 with ...
echo "header('Location : http://' . {$_SERVER['SERVER_NAME']} . '/SearchPage.php');";
Added {} around the $_SERVER['SERVER_NAME'] variable.
The code in the snippet is debugging code. I would expect you to put it in the action scripts as they are the ones you say you are having a problem with.
ASKER
ASKER
Hi
I have 2 pages callled asset_move.php and asset_move.do.php.
The first page (asset_move.php) get's the values and the (asset_move.do.php) does the update based in input from (asset_move.php). This is basically for all my other pages.
I have 2 pages callled asset_move.php and asset_move.do.php.
The first page (asset_move.php) get's the values and the (asset_move.do.php) does the update based in input from (asset_move.php). This is basically for all my other pages.
First Page (asset_move.php)
When I debug this I get
_GET
Array
(
)
_POST
Array
(
[assetID] => 17
)
_SESSION
Array
(
[branch] => NTOP10IT06
[assetID] => 17
)
_COOKIE
Array
(
[PHPSESSID] => 2c7157fea4c229b8eca10076bb539d5e
)
_FILES
Array
(
)
<?php
session_start();
// DEBUG : Show what information we have been supplied or have available.
echo '<pre>';
foreach(array('GET', 'POST', 'SESSION', 'COOKIE', 'FILES') as $s_Array)
{
$s = "_$s_Array";
echo "<br /><br />$s<br />";
print_r($$s);
}
echo '</pre>';
// If we get to this page with no branch being known, then go straight to the SearchPage.
if (!isset($_POST['assetID']))
{
header('Location : http://' . $_SERVER['SERVER_NAME'] . '/SearchPage.php');
exit();
}
// If a branch has been requested then remember the branch
elseif (isset($_POST['assetID']))
{
$_SESSION['assetID'] = $_POST['assetID'];
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>Move Asset</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php include "Menu.php"; ?>
<form action="asset_move.do.php" method="post">
<table border="5" cellspacing="2">
<tr>
<th>New CostCode</th>
<th>Change Order number Required</th>
</tr>
<tr>
<td><input type="text" name="newcostcode" ></td>
<td><input type="text" name="changeorder"></td>
</tr>
</table>
<br>
<input type="submit" value="submit">
</form>
<?php
echo '$_GET = ';
print_r($_GET);
echo '$_POST = ';
print_r($_POST);
?>
</body>
</html>
Second Page (asset_move.do.php)
I get a blank page and it does not update
<?php
session_start();
// DEBUG : Show what information we have been supplied or have available.
echo '<pre>';
foreach(array('GET', 'POST', 'SESSION', 'COOKIE', 'FILES') as $s_Array)
{
$s = "_$s_Array";
echo "<br /><br />$s<br />";
print_r($$s);
}
echo '</pre>';
// If we get to this page with no branch being known, then go straight to the SearchPage.
if (!isset($_POST['assetID']))
{
header('Location : http://' . $_SERVER['SERVER_NAME'] . '/SearchPage.php');
exit();
}
// If a branch has been requested then remember the branch
elseif (isset($_POST['assetID']))
{
$_SESSION['assetID'] = $_POST['assetID'];
}
define("DB_HOST","localhost");
define("DB_USER","ServiceDesk");
define("DB_PASS","ServiceDesk");
define("DB_NAME","AssetDB");
$db_connection = mssql_connect(DB_HOST, DB_USER, DB_PASS) or die ("Could not connect to MSSQL host:<br>".mssql_get_last_message());
$result = mssql_select_db(DB_NAME, $db_connection);
if(!$result) exit("Could not select MSSQL DB:<br>".mssql_get_last_message());
//-- Validate the Change order againts Service Desk Database and insert it to the AssetDB Error on this message
//$conn2 = mssql_connect("CASQL","ServiceDesk","Un1c3nt3r") or die ("Could not connect to the MSSQL database:<br>".mssql_get_last_message());
//$results = mssql_select_db("MDB",$conn2);
//if(!$results) exit ("Could not select MSSQL database:<br>".mssql_get_last_message());
$query = "Select * from Branch Where BranchCostCode = '" .$_POST['newcostcode'] . "'";
$result = mssql_query($query,$db_connection);
if (!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0)
//-- Check if Change Exist in ServiceDesk Database - Error on this message
//$query = "Select * from chg Where chg_ref_num = '" .$_POST['changeorder']."'";
//$result = mssql_query($query,$conn2);
//if(!$result) exit("Could not execute query:<br>$query");
//if(mssql_num_rows($result) == 0)
{
$conn2 = mssql_connect("OLTP1","ServiceDesk","servicedesk") or die ("Could not connect to MSSQL database:<br>".mssql_get_last_message());
$result = mssql_select_db("HRFOCUS",$conn2);
if(!$result) exit("Could not select MSSQL database:<br>".mssql_get_last_message());
$query = "Select * from dbo.zEmployee_ITReport Where Manager_Name is not null And Cost_center = '" .$_POST['newcostcode'] ."'";
$result = mssql_query($query,$conn2);
if(!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0) exit("Cost Code not found in HR Table");
$row = mssql_fetch_array($result);
$query = "Insert into Branch (BranchManager,BranchCostCode,Branchname,ChangeOrder) values ('".$row['Manager_name']."','".$row['Cost_Center']."','".$row['Location']."','".$_POST['changeorder']."') ";
//$query = "Insert into Branch (BranchManager,BranchCostCode,Branchname) values (".$row['Manager_name'].",".$row['Cost_Center'].",".$row['Location'].")";
$result = mssql_query($query,$db_connection);
if(!$result) exit("Could not insert new data:<br>$query<br>".mssql_get_last_message());
$query = "SELECT BranchID FROM Branch WHERE BranchCostCode = '".$_POST['newcostcode']."'";
$result = mssql_query($query, $db_connection);
//$row = mssql_fetch_array($result);
//$branch_id = $row['BranchID'];
$a_Branch = mssql_fetch_assoc($result);
$query = "UPDATE Asset_Branch_Link SET BranchID = {$a_Branch['BranchID']} WHERE AssetID = '{$a_Branch['assetID']}'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query<br>".mssql_get_last_message());
} else {
$a_Branch = mssql_fetch_assoc($result);
//$branch_id = $row['BranchID'];
$query = "UPDATE Asset_Branch_Link SET BranchID = {$a_Branch['BranchID']} WHERE AssetID = '{$a_Branch['assetID']}'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query<br>".mssql_get_last_message());
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Asset Moved</title>
</head>
<body>
<?php include "Menu.php"; ?>
<form action="search.php" method="post">
<input type="hidden" value="<?php echo $_SESSION['cost_code']; ?>" name="branch">
Asset successfully moved!<br>
<input type="Submit" value="Click here to return to search page">
</form>
<?php
echo '$_GET = ';
print_r($_GET);
echo '$_POST = ';
print_r($_POST);
?>
</body>
</html>
NO!!!!!!!!!!!!!
PLEASE READ MY COMMENTS PROPERLY.
The whole point was to NOT do the redirect but to echo WHERE the redirect was going to go.
This is ***debugging***.
When you redirect, any output previously generated will generate an error and I'm trying to find out what your code is doing.
Can you get the site onto a LIVE server?
PLEASE READ MY COMMENTS PROPERLY.
The whole point was to NOT do the redirect but to echo WHERE the redirect was going to go.
This is ***debugging***.
When you redirect, any output previously generated will generate an error and I'm trying to find out what your code is doing.
Can you get the site onto a LIVE server?
ASKER
THis is the bedug from the asset_move.do.php with errors
_GET
Array
(
)
_POST
Array
(
[newcostcode] => NTOP10IT06
[changeorder] => CO1987654
)
_SESSION
_COOKIE
Array
(
[PHPSESSID] => 2c7157fea4c229b8eca10076bb 539d5e
)
_FILES
Array
(
)
Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\AssetMa nagement\a sset_move. do.php:4) in C:\Inetpub\wwwroot\AssetMa nagement\a sset_move. do.php on line 16
_GET
Array
(
)
_POST
Array
(
[newcostcode] => NTOP10IT06
[changeorder] => CO1987654
)
_SESSION
_COOKIE
Array
(
[PHPSESSID] => 2c7157fea4c229b8eca10076bb
)
_FILES
Array
(
)
Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\AssetMa
GET RID OF THE REDIRECT.
ECHO IT INSTEAD.
Like this ...
echo "header('Location : http://' . $_SERVER['SERVER_NAME'] . '/SearchPage.php');";
ECHO IT INSTEAD.
Like this ...
echo "header('Location : http://' . $_SERVER['SERVER_NAME'] . '/SearchPage.php');";
ASKER
Hi
Here is the output of 2 php pages (asset_move.php & asset_move.do.php)
Output of asset_move.php
_GET
Array
(
)
_POST
Array
(
[assetID] => 17
)
_SESSION
Array
(
[branch] => NTOP10IT06
[assetID] => 17
)
_COOKIE
Array
(
[PHPSESSID] => 3b3be2167bf9cceb9571e85cf9 9d05b4
)
_FILES
Array
(
)
$_GET = Array ( ) $_POST = Array ( [assetID] => 17 )
Here is the output of 2 php pages (asset_move.php & asset_move.do.php)
Output of asset_move.php
_GET
Array
(
)
_POST
Array
(
[assetID] => 17
)
_SESSION
Array
(
[branch] => NTOP10IT06
[assetID] => 17
)
_COOKIE
Array
(
[PHPSESSID] => 3b3be2167bf9cceb9571e85cf9
)
_FILES
Array
(
)
$_GET = Array ( ) $_POST = Array ( [assetID] => 17 )
out put of the second page (asset_move.do.php)
_GET
Array
(
)
_POST
Array
(
[newcostcode] => NTOP10IT06
[changeorder] => CO789456
)
_SESSION
Array
(
[branch] => NTOP10IT06
[assetID] => 17
)
_COOKIE
Array
(
[PHPSESSID] => 3b3be2167bf9cceb9571e85cf99d05b4
)
_FILES
Array
(
)
header('Location : http://' . usvddev . '/SearchPage.php');
Ah. I see.
On the xxx_do.php pages, the assetID is not sent via POST as it is in the session.
A "belt and braces" approach would be to add the following code to the action scripts
<input type="hidden" name="assetID" value="<?php echo $_SESSION['assetID']; ?>" />
This should fix things.
On the xxx_do.php pages, the assetID is not sent via POST as it is in the session.
A "belt and braces" approach would be to add the following code to the action scripts
<input type="hidden" name="assetID" value="<?php echo $_SESSION['assetID']; ?>" />
This should fix things.
<input type="submit" value="submit">
</form>
becomes
<input type="submit" value="submit">
<input type="hidden" name="assetID" value="<?php echo $_SESSION['assetID']; ?>" />
</form>
Ok?
</form>
becomes
<input type="submit" value="submit">
<input type="hidden" name="assetID" value="<?php echo $_SESSION['assetID']; ?>" />
</form>
Ok?
ASKER
Hi
Yes I get no errors the things is now is when moving one Asset to a other cost code is does not update. Because e.g Asset ID 17 cost code is (NTOP10IT06) and I move it to (RCL2). It doe snot update, yet I have set in my sql code
Yes I get no errors the things is now is when moving one Asset to a other cost code is does not update. Because e.g Asset ID 17 cost code is (NTOP10IT06) and I move it to (RCL2). It doe snot update, yet I have set in my sql code
$query = "Select * from Branch Where BranchCostCode = '" .$_POST['newcostcode'] . "'";
$result = mssql_query($query,$db_connection);
if (!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0)
//-- Check if Change Exist in ServiceDesk Database - Error on this message
//$query = "Select * from chg Where chg_ref_num = '" .$_POST['changeorder']."'";
//$result = mssql_query($query,$conn2);
//if(!$result) exit("Could not execute query:<br>$query");
//if(mssql_num_rows($result) == 0)
{
$conn2 = mssql_connect("OLTP1","ServiceDesk","servicedesk") or die ("Could not connect to MSSQL database:<br>".mssql_get_last_message());
$result = mssql_select_db("HRFOCUS",$conn2);
if(!$result) exit("Could not select MSSQL database:<br>".mssql_get_last_message());
$query = "Select * from dbo.zEmployee_ITReport Where Cost_center = '" .$_POST['newcostcode'] ."'";
$result = mssql_query($query,$conn2);
if(!$result) exit("Could not execute query:<br>$query");
if(mssql_num_rows($result) == 0) exit("Cost Code not found in HR Table");
$row = mssql_fetch_array($result);
$query = "Insert into Branch (BranchManager,BranchCostCode,Branchname,ChangeOrder) values ('".$row['Manager_name']."','".$row['Cost_Center']."','".$row['Location']."','".$_POST['changeorder']."') ";
//$query = "Insert into Branch (BranchManager,BranchCostCode,Branchname) values (".$row['Manager_name'].",".$row['Cost_Center'].",".$row['Location'].")";
$result = mssql_query($query,$db_connection);
if(!$result) exit("Could not insert new data:<br>$query<br>".mssql_get_last_message());
$query = "SELECT BranchID FROM Branch WHERE BranchCostCode = '".$_POST['newcostcode']."'";
$result = mssql_query($query, $db_connection);
//$row = mssql_fetch_array($result);
//$branch_id = $row['BranchID'];
$a_Branch = mssql_fetch_assoc($result);
$query = "UPDATE Asset_Branch_Link SET BranchID = {$a_Branch['BranchID']} WHERE AssetID = '{$a_Branch['assetID']}'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query<br>".mssql_get_last_message());
} else {
$a_Branch = mssql_fetch_assoc($result);
//$branch_id = $row['BranchID'];
$query = "UPDATE Asset_Branch_Link SET BranchID = {$a_Branch['BranchID']} WHERE AssetID = '{$a_Branch['assetID']}'";
$result = mssql_query($query, $db_connection);
if(!$result) exit("Could not execute query:<br>$query<br>".mssql_get_last_message());
}
?>
ASKER
Asset_move.php
asset-move.txt
asset-move.txt
ASKER
Asset_move.do.php
asset-move-do.txt
asset-move-do.txt
I'm not being rude, but do you want to hire me as a consultant?
ASKER
Hi
Sorry no
Sorry no
<input name='changeCheck' type='radio' value='".$row['AssetID']."