I have a set of pages I've been working on to do address entry for
registered users to a MySQL database. I'm running up against a wall that
I've been fighting for two days...
process is thus:
checks session vars to see if user is logged in. if not, present login screen.
if logged in:
see if this is a submitted form, or a blank request for one.
if blank request, present the HTML form.
if submitted:
check the incoming data to determine if the address type (home, work or
other) is set. if not, give error.
if set, checks to see if that type was already in the database for that user,
and checks to see if this address was flagged as the mailing address. if
either case, give error and exit.
past all that? The the script SHOULD run the mysql_query and insert the
submitted data to the database.
if successful, should return one of two options: either go to the site
main index page, or
reload a blank address form if the user wants to enter an additional address.
My problem is coming in AFTER the type and mailing checks, and before the
mysql_query. I can't
find any problems with the script; everything looks right to me. However:
if I fill out the form and leave out the type field, I get the correct error.
if I mark a type that exists in the database already, or that type already
has a mailing flag set, I get the correct error.
if I fill out the form correctly, and hit either button, I get a Netscape
error "Document Contains No Data".
What in tarnation is going on? Can someone help me please?
Robert Cooper
AwakeningRetreat.Net Webmaster
----- Attached script below address.php -----
<?
require("backend.php");
session_start();
session_register("refer");
$refer = "/register/address.php";
if (!$seslog) {
header("Location: /register/login.php");
exit;
}
else {
$username = $sesusername;
$id = $sesid;
if (isset($street)) {
if (!$type) {
include("header.html");
echo "<P><CENTER><FONT SIZE=+2>Must Specify address type.</FONT><BR>
<FONT SIZE=+1>Click the back arrow on your browser, select a
type, and
resubmit.<P>
<a href=\"http://www.awakeningretreat.net/\">Continue without
entering
address information.</FONT></CENTER>";
include("footer.html");
exit;
}
else {
mysql_connect("localhost","www","") or
die("Unable to connect to SQL server");
mysql_select_db("awakening") or die("Unable to select database");
$query = mysql_query("select type, mailing from address where
id='$id'");
$result = mysql_num_rows($query);
if ($result > 0 ) {
while ($row = mysql_fetch_array($query)) {
if ($row[type] == $type) echo "$type address already
exists in
database. <a href=\"/register/address.php\"> Back to address entry.</a><P>";
if ($row[mailing] == $mailing) echo "You have already
defined
$row[type] as mailing address. <a href=\"/register/address.php\"> Back to
address entry.</a><P>";
}
exit;
}
else {
$result = mysql_query("INSERT INTO address VALUES ('$id', '$street',
'$city', '$state', '$ZIP', '$type', '$mailing')");
if (!$result) {
echo "Unknown database error in address.<BR>
Please contact the <a
href=\"mailto:[EMAIL PROTECTED]\">Webmaster</a>
with this information.";
exit;
}
else {
include("header.html");
echo "<P>Finished updating addresses.";
include("footer.html");
switch ($action) {
case "Finish" :
header("Location: http://www.awakeningretreat.net/");
break;
case "Add Another" :
header("Location: /register/address.php");
break;
}
}
}
}
}
else {
include("header.html");
echo "
<CENTER>
<FONT SIZE=+2>Address Information</FONT>
<P>
<FORM ACTION=\"address.php\" METHOD=\"POST\">
<table border=0 cellspacing=0 cellpadding=0>
<TR><td align=right>Street : </td><td><input type=text
name=street></td></tr>
<TR><td align=right>City : </td><td><input type=text name=city></td></tr>
<TR><td align=right>State : </td><td><input type=text name=state
SIZE=2></td></tr>
<TR><td align=right>ZIP : </td><td><input type=text name=ZIP
SIZE=10></td></tr>
<TR><td align=right>Address Type : </TD><TD><input type=radio name=type
value=home>HOME
<input type=radio name=type value=work>WORK<input type=radio name=type
value=other>OTHER
</SELECT></TD></TR>
<TR><td> </TD><TD><input type=checkbox name=mailing value=\"Y\"> This
is my Mailing Address</TD></TR>
<TR><td align=right>Submit and:</td><td><input type=submit
value=\"Finish\" name=\"action\"> <input type=submit value=\"Add Another\"
name=\"action\"></td></tr>
<TR><TD COLSPAN=2 ALIGN=CENTER><a
href=\"http://www.awakeningretreat.net/\">OR: continue without entering
address information.</TD></TR>
</table>
</CENTER>
NOTES: <a href=\"/privacy.php\">Privacy Policy</a><BR>
All fields on this page are optional. However, answering them will help
other Awakeners find you!<BR>
<P>
</form>
";
include("footer.html");
}
}
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]