473,406 Members | 2,956 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,406 software developers and data experts.

error on POSTed form

Wm
I'm having a very hard time trying to add an edited listing to mySQL. I'm
breaking this in to two halves, so that each error/problem can [hopefully]
be pinpointed.

The edit form queries mySQL and fills in a form with their existing
information (identical form to the original "Add Me" form, but this time
echo'ing the data currently in mySQL). This part works great. Once they
have edited their information, Submit takes them to a page called save.php.
Now the problems start. Below are my errors, followed by the section of the
code to which they are referring. The errors are all fields where checkboxes
were UNchecked -- the variables that were checked are not cited as errors.

Warning: Undefined index: hair in /home/httpd/httpdocs/html/save.php on line
33
Warning: Undefined index: tv in /home/httpd/httpdocs/html/save.php on line
36
Warning: Undefined index: film in /home/httpd/httpdocs/html/save.php on line
37
Warning: Undefined index: bridal in /home/httpd/httpdocs/html/save.php on
line 39

My code, beginning at line 20, is:
<?PHP
error_reporting (E_ALL);
$firstname = (ucwords(strtolower(trim($_POST['firstname']))));
$lastname = (ucwords(strtolower(trim($_POST['lastname']))));
$city= (ucwords(strtolower(trim($_POST['city']))));
$state= (strtoupper($_POST['state']));
$country= (strtoupper($_POST['country']));
$availability= (addslashes($_POST['availability']));
$experience= (addslashes($_POST['experience']));
$email= (strtolower($_POST['email']));
$website= (strtolower($_POST['website']));
$newpasswd = ($_POST['website']);
$makeup = ($_POST['makeup']);
$hair = ($_POST['hair']);
$wardrobe = ($_POST['wardrobe']);
$print = ($_POST['print']);
$tv = ($_POST['tv']);
$film = ($_POST['film']);
$video = ($_POST['video']);
$bridal = ($_POST['bridal']);
$artistID = ($_POST['artistID']);

FWIW, I have tried the checkboxes both with and without the ( ) around the
$_POST... Do I have to handle anything differently to account for UNchecked
checkboxes, which presumably aren't passed?

Thanx!
Wm



Jul 16 '05 #1
2 2589
>Do I have to handle anything differently to account for UNchecked
checkboxes, which presumably aren't passed.

These variables are passed but are passed as null or empty values.

Try an function such like is_null($i) or empty($i)

eg

if ((is_null($i)) || (!empty($i))){
.....
}
reference : http://us4.php.net/manual/en/function.empty.php
http://us4.php.net/manual/en/function.is-null.php
-JD

"Wm" <LA*******@hotmail.com> wrote in message
news:3Y**********************@news.easynews.com... I'm having a very hard time trying to add an edited listing to mySQL. I'm
breaking this in to two halves, so that each error/problem can [hopefully]
be pinpointed.

The edit form queries mySQL and fills in a form with their existing
information (identical form to the original "Add Me" form, but this time
echo'ing the data currently in mySQL). This part works great. Once they
have edited their information, Submit takes them to a page called save.php. Now the problems start. Below are my errors, followed by the section of the code to which they are referring. The errors are all fields where checkboxes were UNchecked -- the variables that were checked are not cited as errors.

Warning: Undefined index: hair in /home/httpd/httpdocs/html/save.php on line 33
Warning: Undefined index: tv in /home/httpd/httpdocs/html/save.php on line
36
Warning: Undefined index: film in /home/httpd/httpdocs/html/save.php on line 37
Warning: Undefined index: bridal in /home/httpd/httpdocs/html/save.php on
line 39

My code, beginning at line 20, is:
<?PHP
error_reporting (E_ALL);
$firstname = (ucwords(strtolower(trim($_POST['firstname']))));
$lastname = (ucwords(strtolower(trim($_POST['lastname']))));
$city= (ucwords(strtolower(trim($_POST['city']))));
$state= (strtoupper($_POST['state']));
$country= (strtoupper($_POST['country']));
$availability= (addslashes($_POST['availability']));
$experience= (addslashes($_POST['experience']));
$email= (strtolower($_POST['email']));
$website= (strtolower($_POST['website']));
$newpasswd = ($_POST['website']);
$makeup = ($_POST['makeup']);
$hair = ($_POST['hair']);
$wardrobe = ($_POST['wardrobe']);
$print = ($_POST['print']);
$tv = ($_POST['tv']);
$film = ($_POST['film']);
$video = ($_POST['video']);
$bridal = ($_POST['bridal']);
$artistID = ($_POST['artistID']);

FWIW, I have tried the checkboxes both with and without the ( ) around the
$_POST... Do I have to handle anything differently to account for UNchecked checkboxes, which presumably aren't passed?

Thanx!
Wm


Jul 16 '05 #2
On Sat, 16 Aug 2003 22:44:36 GMT, "Jamie Davison" <ja***@bardavon.org> wrote:
Do I have to handle anything differently to account for UNchecked
checkboxes, which presumably aren't passed.


These variables are passed but are passed as null or empty values.

Try an function such like is_null($i) or empty($i)

eg

if ((is_null($i)) || (!empty($i))){
.....
}


No, they're not passed at all. Only 'successful' controls (as defined in the
HTML specs) are passed. A set variable or array element with a NULL or empty
value is distinct from an unset variable.

Use isset() to determine if the variable has been passed or not.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>form test</title>
</head>
<body>
<form action="" method="get">
<input type="checkbox" name="check1" value="T">
<input type="submit">
</form>
<hr>
<pre>
<?php
print_r($_GET);
?>
</body>
</pre>
</html>

Submit this form with and without the checkbox set; you'll see that check1 is
NOT passed as a null or empty value if the checkbox is unchecked, it simply is
not passed at all.

Checked:

Array
(
[check1] => T
)

Unchecked:

Array
(
)

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #3

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

Similar topics

1
by: dmiller23462 | last post by:
Hey guys.... I put an error-handling in my page and have it posted at the complete end of the code, see below(when people were putting in 's I was getting the delimiter errors). Great, I...
8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
2
by: Julia Baresch | last post by:
Hi everyone, As some of you may know, we've been having trouble with an unrecognized database format error. Today I installed an unfinished project on the workstation of one of my users. ...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
17
by: ronaldlee | last post by:
I have this error in Line 89. Collection is read-only. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more...
7
by: ddd | last post by:
Hi, I am having problems with using the DrawToDC of the MSHTML.iHTMLElementRender in a VB.net application. For some reason I am getting a "catastrophic error". I am basing the code on c#...
10
by: robert d via AccessMonster.com | last post by:
I have a global error handler that up until today has been working flawlessly. Let me first provide the relevant code **************************************************************** On Error...
2
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%=...
11
by: JRough | last post by:
I'm trying to use output buffering to cheat so i can print to excel which is called later than this header(). header("Content-type: application/xmsdownload"); header("Content-Disposition:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.