473,395 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Weird argument passing problem

Hi all:

I have a really weird problem. I am developing a customer catalog
system for my company and as such have delved into sessions for
authentication and access levels. So far, I have managed to get a
working system just about finished.

I am building an interface for our customer service folks to use to
manage registered customers and am seeing some weird behavior.

Basically, the main "my" page calls a page - managecust.php. That page
lists a synopsis of the contents of the users DB and the last cell of
each row contains an 'edit' and 'delete' option.

The edit option is a hyperlink of the type custedit.php?id='xx' where
the 'xx' is the id returned during the initial search of the DB (using
a select * from db).

Theoretically, when the user clicks the edit link beside the
appropriate record, the custedit.php page is called with the id # of
the record being passed.

The weird part is that even though the URL passed is correct, the page
"remembers" which ever record was chosen FIRST.

managecust.php code:
---------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<title>International Enterprises, Inc. Depot Level F16 Avionics
Repair</title>
</head>

<body>

<?
include('css/header.php');
include('css/functions.php');
buildhead("Customer Data Management");
?>

<BR />
<div align="center">

<H3 class=bordered>Customer Data Management</H3>
<BR />

<TABLE CLASS=form BORDER=1 CELLSPACING=2 CELLPADDING=2>
<TR>
<TD>First Name</TD>
<TD>Last Name</TD>
<TD>Company Name</TD>
<TD>Login ID</TD>
<TD>Access Level</TD>
<TD>Options</TD>
</TR>
<?
// Setup pagination so we can browse the data set
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}

// Count the rows in the DB
connectDB("xxxxxx");
$query = "SELECT count(*) FROM xxxxxxx";
$result = mysql_query($query) or trigger_error("SQL",E_USER_ERROR);
$query_data = mysql_fetch_row($result);
$numrows = $query_data[0];

// Calculate the number for $lastpage
$rows_per_page = 15; // We only want 15 rows per page. Adjust to fit
tastes.
$lastpage = ceil($numrows/$rows_per_page);

// Ensure that $pageno is within range
$pageno = (int)$pageno;
if ($pageno < 1) {
$pageno = 1;
} elseif ($pageno > $lastpage) {
$pageno = $lastpage;
} else {
$pageno = $pageno;
}

// Construct the LIMIT clause we will use
$limit = 'LIMIT '.($pageno - 1) * $rows_per_page. ','.$rows_per_page;

// Issue the actual query for data from the DB and process the results
$sql="SELECT * from reginfo ORDER BY lname,fname $limit";
// echo $sql."<BR />";
$result = mysql_query($sql) or die("Error reading from database
reginfo: ".mysql_error());

while($myrow=mysql_fetch_array($result)) {
echo "<TR>";
echo "<TD CLASS=data>".$myrow['fname']."</TD>";
echo "<TD CLASS=data>".$myrow['lname']."</TD>";
echo "<TD CLASS=data>".$myrow['coname']."</TD>";
echo "<TD CLASS=data>".$myrow['login']."</TD>";
echo "<TD CLASS=data>".$myrow['level']."</TD>";
echo "<TD CLASS=data>
<A HREF=custedit.php?id=".$myrow['id'].">Edit</A> |
<A HREF=delcust.php?id=".$myrow['id'].">Delete</A></TD></TR>";
}
?>
</TABLE>
<BR />

<?
pagethru($pageno,$lastpage)?>
</div>
<br />

<? include('css/footer.php'); ?>
</div>
</body>

custedit.php
--------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<title>International Enterprises, Inc. Depot Level F16 Avionics
Repair</title>

<meta name="Copyright" content="Copyright (c) International
Enterprises, Inc. 2004" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>

<?
include('css/header.php');
include('css/functions.php');
buildhead("Edit Customer Information");
?>
<BR />

<?

if ($submit) {
// Connect to the DB and update the record
connectDB("xxxxxx");
$sql = "UPDATE xxxxxx SET
fname='$fname',lname='$lname',coname='$coname',add 1='$add1',add2='$add2',
city='$city',state='$state',zip='$zip',country='$c ountry',phone='$phone',login='$login',
email='$email',level='$level' WHERE id=$id";

$result = mysql_query($sql) or die("Error updating record:
".mysql_error());

if (isset ($_POST['sendemail'])) {
// send a response to the submitter.
$to=$email;
// email message and header stuff here
}

echo '<meta http-equiv="refresh" content="0; URL=managecust.php">"';

} else {
// Connect to the DB and retrieve the record
connectDB("catalog");
$sql = "SELECT * FROM reginfo WHERE id='$id'";
$result = mysql_query($sql) or die("Error retrieving record:
".mysql_error());

while ($myrow=mysql_fetch_array($result)) {
?>

<DIV ALIGN="CENTER">
<H3 CLASS=bordered>Edit Customer Information</H3>
<BR />

<FORM METHOD=post ACTION='custedit.php'>
<TABLE CLASS=form BORDER="0">
<TR>
<TD ALIGN=center COLSPAN=3>Please edit any items and submit to
update record</TD>
</TR>
<TR><TD></TD></TR>
<TR>
<TD ALIGN=right>First Name</TD>
<TD><INPUT TYPE="text" NAME=fname SIZE=50 VALUE="<?= $myrow['fname']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Last Name</TD>
<TD><INPUT TYPE="text" NAME=lname SIZE=50 VALUE="<?= $myrow['lname']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Company Name</TD>
<TD><INPUT TYPE="text" NAME=coname SIZE=50 VALUE="<?=
$myrow['coname'] ?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Address</TD>
<TD><INPUT TYPE="text" NAME=add1 SIZE=50 VALUE="<?= $myrow['add1']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Address</TD>
<TD><INPUT TYPE="text" NAME=add2 SIZE=50 VALUE="<?= $myrow['add2']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>City</TD>
<TD><INPUT TYPE="text" NAME=city SIZE=50 VALUE="<?= $myrow['city']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>State</TD>
<TD><INPUT TYPE="text" NAME=state SIZE=50 VALUE="<?= $myrow['state']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Zip/Postal Code</TD>
<TD><INPUT TYPE="text" NAME=zip SIZE=50 VALUE="<?= $myrow['zip']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Country</TD>
<TD><INPUT TYPE="text" NAME=country SIZE=50 VALUE="<?=
$myrow['country'] ?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Phone</TD>
<TD><INPUT TYPE="text" NAME=phone SIZE=50 VALUE="<?= $myrow['phone']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Email</TD>
<TD><INPUT TYPE="text" NAME=email SIZE=50 VALUE="<?= $myrow['email']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Login</TD>
<TD><INPUT TYPE="text" NAME=login SIZE=50 VALUE="<?= $myrow['login']
?>"></TD>
</TR>
<TR>
<TD ALIGN=right>Access Level</TD>
<TD>
<SELECT NAME="level">
<OPTION VALUE=99>No Pricing</OPTION>
<OPTION VALUE=1>Base Price</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD>Send Credentials via Email</TD>
<TD><INPUT TYPE="checkbox" VALUE="sendemail" NAME="sendemail"></TD>
</TR>
</TABLE>
<?
}
?>

<BR>
<DIV ALIGN="CENTER">
<INPUT TYPE="submit" NAME="submit" VALUE=Update>
<INPUT TYPE="reset" NAME="reset" VALUE=Reset />
</DIV>
</FORM>
<?
}
?>

<br />

<? include('css/footer.php'); ?>
</div>
</body>
Can anyone tell me why this is happening? If I paste the URL directly,
all works well.

TIA

rk

Jul 17 '05 #1
3 2054
Not sure if this will help, but it is a good idea to combine your GET
and POST vars into an array.

$attributes = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS)
This makes longer scripts easier to understand.

Jul 17 '05 #2
Not sure if this will help, but it is a good idea to combine your GET
and POST vars into an array.

$attributes = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS)
This makes longer scripts easier to understand.


or use $_REQUEST, which is a combination of get/post/cookies.

longer scripts rather need to use get/post in one place only,
and use functions or classes for futher operation on acquired data.
--
* html {redirect-to: url(http://browsehappy.pl);}
Jul 17 '05 #3
Actually, using $_GET['id'] at the start of the main ELSE structure on
the custedit.php page solved the problem. Thanks to everyone for the
input.

rk

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Frank Bechmann | last post by:
Eventually most of you will not learn much from this because it's just another event in the 'default argument value gotcha' series, but because it cost me some hours yesterday to spot this 'error'...
8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
11
by: Anon Email | last post by:
Hey people, This looks really weird. I can't make sense of it. Is this a mistake? Can anyone help? IStack const & GetStack () const; Cheers,
17
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int...
2
by: Alexander Fedin | last post by:
Guys, I 've met some strange behaviour of the C# compiler. To reproduce it please try to compile the code below and you 'll be really amazed. The problem is that you can not use an interface...
3
by: matko | last post by:
This is a long one, so I'll summarize: 1. What are your opinions on raising an exception within the constructor of a (custom) exception? 2. How do -you- validate arguments in your own...
8
by: A. Anderson | last post by:
Howdy everyone, I'm experiencing a problem with a program that I'm developing. Take a look at this stack report from GDB - #0 0xb7d782a3 in strlen () from /lib/tls/i686/cmov/libc.so.6 #1 ...
16
by: Bill Nguyen | last post by:
I'm running into a very weird problem regarding subtraction. Subtraction behaves as if it's an addition in the below sub txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0") ...
6
by: zhangsonglovexiaoniuniu | last post by:
Dear all, I need you help. here the program: char a = 0x91; printf("%x",a);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.