Website Membership: How to Remove "Error Checking"

By yusuke - September 5, 2010

Hi,

I have a problem removing error checking.
When I simply remove error checking lines, I get the below error message.
Notice: Undefined variable: errorsAndAlerts in /home/keepstock-s/www/php/profile_coupon.php on line 18
What am I doing wrong?
Here is the code.
<?php require_once"/home/keepstock-s/www/hairsalon/lib/viewer_functions.php"; ?>

<?php if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("ƒƒ“ƒo[ƒy[ƒW‚ª‹N“®‚µ‚Ä‚¢‚Ü‚¹‚ñB"); } ?>
<?php if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); } ?>
<?php

// prepopulate form with current user values
foreach ($CURRENT_USER as $name => $value) {
if (array_key_exists($name, $_REQUEST)) { continue; }
$_REQUEST[$name] = $value;
}

// process form
if (@$_REQUEST['save']) {

// error checking
$errorsAndAlerts = "";
if (!@$_REQUEST['couponname1']) { $errorsAndAlerts .= "ƒN[ƒ|ƒ“–¼1‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['couponcontents1']) { $errorsAndAlerts .= "ƒN[ƒ|ƒ““à—e1‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['couponname2']) { $errorsAndAlerts .= "ƒN[ƒ|ƒ“–¼2‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['couponcontents2']) { $errorsAndAlerts .= "ƒN[ƒ|ƒ““à—e2‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['couponname3']) { $errorsAndAlerts .= "ƒN[ƒ|ƒ“–¼3‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['couponcontents3']) { $errorsAndAlerts .= "ƒN[ƒ|ƒ““à—e3‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }

// update user
if (!$errorsAndAlerts) {
mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)
if (@$_REQUEST['newPassword2']) { $CURRENT_USER['password'] = $_REQUEST['newPassword2']; } // update password
$query = "UPDATE `{$TABLE_PREFIX}accounts` SET
couponname1 = '".mysql_escape( $_REQUEST['couponname1'] )."',
couponcontents1 = '".mysql_escape( $_REQUEST['couponcontents1'] )."',
couponname2 = '".mysql_escape( $_REQUEST['couponname2'] )."',
couponcontents2 = '".mysql_escape( $CURRENT_USER['couponcontents2'] )."',
couponname3 = '".mysql_escape( $_REQUEST['couponname3'] )."',
couponcontents3 = '".mysql_escape( $_REQUEST['couponcontents3'] )."',

updatedByUserNum = '".mysql_escape( $CURRENT_USER['num'] )."',
updatedDate = NOW()
WHERE num = '".mysql_escape( $CURRENT_USER['num'] )."'";
mysql_query($query) or die("MySQL ƒGƒ‰[F<br/>\n". htmlspecialchars(mysql_error()) . "\n");
$userNum = mysql_insert_id();

// on success
unset($_REQUEST['oldPassword'], $_REQUEST['newPassword1'], $_REQUEST['newPassword2']); // clear password fields
$errorsAndAlerts = "ƒƒ“ƒo[î•ñ‚͍XV‚³‚ê‚Ü‚µ‚½B";
}

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>”ü—eŽºƒVƒ‡ƒbƒvî•ñ“o˜^-Stock</title>
<link href="../css/member_profile.css" rel="stylesheet" type="text/css" media="screen,tv,projection" />
</head>
<body>

<div id="wrapper">
<div id="header">
<h1><a href="index.html">”ü—eŽºE”ü—e‰@]ƒN[ƒ|ƒ““o˜^</a></h1>
<p id="oner"><a href="../oner_entrance.html">”ü—eŽºƒI[ƒi[—l“üŒû</a></p>
<!--end div#header-->
</div>
<div id="coupon">
<h2>ƒN[ƒ|ƒ““o˜^</h2>
<div id="php_profile">
<!-- ƒvƒƒtƒB[ƒ‹•ÒWƒtƒH[ƒ€ -->
<?php if (@$errorsAndAlerts): ?>
<div style="color: #C00; font-weight: bold; font-size: 14px; font-family: arial;"><br/>
<?php echo $errorsAndAlerts; ?><br/><br/>
</div>
<?php endif ?>

<form method="post" action="">
<input type="hidden" name="save" value="1" />

<table width="600" cellspacing="4" cellpadding="4">
<tr>
<th scope="col">ƒN[ƒ|ƒ“–¼</th>
<th scope="col">ƒN[ƒ|ƒ““à—e</th>
</tr>
<tr>
<td width="250"><input type="text" name="couponname1" value="<?php echo htmlspecialchars(@$_REQUEST['couponname1']); ?>" size="40" /></td>
<td><textarea name="couponcontents1" cols="50" rows="3"><?php echo htmlspecialchars(@$_REQUEST['couponcontents1']); ?></textarea></td>
</tr>
<tr>
<td width="250"><input type="text" name="couponname2" value="<?php echo htmlspecialchars(@$_REQUEST['couponname2']); ?>" size="40" /></td>
<td><textarea name="couponcontents2" cols="50" rows="3"><?php echo htmlspecialchars(@$_REQUEST['couponcontents2']); ?></textarea></td>
</tr>
<tr>
<td width="250"><input type="text" name="couponname3" value="<?php echo htmlspecialchars(@$_REQUEST['couponname3']); ?>" size="40" /></td>
<td><textarea name="couponcontents3" cols="50" rows="3"><?php echo htmlspecialchars(@$_REQUEST['couponcontents3']); ?></textarea></td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>

<tr>
<td colspan="2" align="center">
<br/><input class="button" type="submit" name="submit" value="XV‚·‚é" />
</td>
</tr>
</table>


</form>
<!-- /ƒvƒƒtƒB[ƒ‹•ÒWƒtƒH[ƒ€ -->
</div>
</div>
<div id="header_menu">
<ul>
<li id="top"><a href="profile.php" title="”ü—eŽºƒVƒ‡ƒbƒvî•ñ">ƒƒ“ƒo[ƒvƒƒtƒB[ƒ‹</a></li>
<li id="salonSearch"><a href="profile_shop.php" title="ƒƒjƒ…[“o˜^">ƒVƒ‡ƒbƒvî•ñ</a></li>
<li id="hairStyle"><a href="profile_menu.php" title="ƒCƒxƒ“ƒgî•ñ">ƒƒjƒ…[“o˜^</a></li>
<li id="special"><a href="profile_picture.php" title="ƒwƒAŽÊ^“o˜^">ƒwƒAŽÊ^“o˜^</a></li>
<li id="Sitemap"><a href="profile_coupon.php" title="ƒN[ƒ|ƒ““o˜^">ƒN[ƒ|ƒ““o˜^</a></li>
</ul>
</div>
<div id="footer">
<ul>
<li><a href="profile_event.php">ƒCƒxƒ“ƒgî•ñ</a></li>
<li><a href="profile_mouth.php">ŒûƒRƒ~ƒR[ƒi[</a></li>
<li><a href="mail.html">‚¨–â‚¢‡‚킹</a></li>
<li><a href="../advertisement.html">LŒfÚ‚ɂ‚¢‚Ä</a></li>
<li><a href="beautysalon_oner.html">ƒTƒƒ“ƒI[ƒi—l‚Ö</a></li>
<li><a href="link.html">ƒŠƒ“ƒN‚ɂ‚¢‚Ä</a></li>
</ul>
<address>
Copyright(C) 2006 ”ü—eŽºE”ü—e‰@]“Œ‹žE‘åãE–¼ŒÃ‰®E•Ÿ‰ªEŽD–yŒŸõŒûƒRƒ~ƒTƒCƒg-Stock All Rights Reserved.
</address>
<!--end div#footer-->
</div>

</div>

</body>
</html>

Will you please help me on this matter?

Re: [yusuke] Website Membership: How to Remove "Error Checking"

By Jason - September 7, 2010

Hi,

You just need to remove all the lines where you use the variable $errorsAndAlerts. Try this code below:

<?php require_once"/home/keepstock-s/www/hairsalon/lib/viewer_functions.php"; ?>

<?php if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("ƒƒ“ƒo[ƒy[ƒW‚ª‹N“®‚µ‚Ä‚¢‚Ü‚¹‚ñB"); } ?>
<?php if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); } ?>
<?php

// prepopulate form with current user values
foreach ($CURRENT_USER as $name => $value) {
if (array_key_exists($name, $_REQUEST)) { continue; }
$_REQUEST[$name] = $value;
}

// process form
if (@$_REQUEST['save']) {

// update user

mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)
if (@$_REQUEST['newPassword2']) { $CURRENT_USER['password'] = $_REQUEST['newPassword2']; } // update password
$query = "UPDATE `{$TABLE_PREFIX}accounts` SET
couponname1 = '".mysql_escape( $_REQUEST['couponname1'] )."',
couponcontents1 = '".mysql_escape( $_REQUEST['couponcontents1'] )."',
couponname2 = '".mysql_escape( $_REQUEST['couponname2'] )."',
couponcontents2 = '".mysql_escape( $CURRENT_USER['couponcontents2'] )."',
couponname3 = '".mysql_escape( $_REQUEST['couponname3'] )."',
couponcontents3 = '".mysql_escape( $_REQUEST['couponcontents3'] )."',

updatedByUserNum = '".mysql_escape( $CURRENT_USER['num'] )."',
updatedDate = NOW()
WHERE num = '".mysql_escape( $CURRENT_USER['num'] )."'";
mysql_query($query) or die("MySQL ƒGƒ‰[F<br/>\n". htmlspecialchars(mysql_error()) . "\n");
$userNum = mysql_insert_id();

// on success
unset($_REQUEST['oldPassword'], $_REQUEST['newPassword1'], $_REQUEST['newPassword2']); // clear password fields

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>”ü—eŽºƒVƒ‡ƒbƒvî•ñ“o˜^-Stock</title>
<link href="../css/member_profile.css" rel="stylesheet" type="text/css" media="screen,tv,projection" />
</head>
<body>

<div id="wrapper">
<div id="header">
<h1><a href="index.html">”ü—eŽºE”ü—e‰@]ƒN[ƒ|ƒ““o˜^</a></h1>
<p id="oner"><a href="../oner_entrance.html">”ü—eŽºƒI[ƒi[—l“üŒû</a></p>
<!--end div#header-->
</div>
<div id="coupon">
<h2>ƒN[ƒ|ƒ““o˜^</h2>
<div id="php_profile">
<!-- ƒvƒƒtƒB[ƒ‹•ÒWƒtƒH[ƒ€ -->

<form method="post" action="">
<input type="hidden" name="save" value="1" />

<table width="600" cellspacing="4" cellpadding="4">
<tr>
<th scope="col">ƒN[ƒ|ƒ“–¼</th>
<th scope="col">ƒN[ƒ|ƒ““à—e</th>
</tr>
<tr>
<td width="250"><input type="text" name="couponname1" value="<?php echo htmlspecialchars(@$_REQUEST['couponname1']); ?>" size="40" /></td>
<td><textarea name="couponcontents1" cols="50" rows="3"><?php echo htmlspecialchars(@$_REQUEST['couponcontents1']); ?></textarea></td>
</tr>
<tr>
<td width="250"><input type="text" name="couponname2" value="<?php echo htmlspecialchars(@$_REQUEST['couponname2']); ?>" size="40" /></td>
<td><textarea name="couponcontents2" cols="50" rows="3"><?php echo htmlspecialchars(@$_REQUEST['couponcontents2']); ?></textarea></td>
</tr>
<tr>
<td width="250"><input type="text" name="couponname3" value="<?php echo htmlspecialchars(@$_REQUEST['couponname3']); ?>" size="40" /></td>
<td><textarea name="couponcontents3" cols="50" rows="3"><?php echo htmlspecialchars(@$_REQUEST['couponcontents3']); ?></textarea></td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>

<tr>
<td colspan="2" align="center">
<br/><input class="button" type="submit" name="submit" value="XV‚·‚é" />
</td>
</tr>
</table>


</form>
<!-- /ƒvƒƒtƒB[ƒ‹•ÒWƒtƒH[ƒ€ -->
</div>
</div>
<div id="header_menu">
<ul>
<li id="top"><a href="profile.php" title="”ü—eŽºƒVƒ‡ƒbƒvî•ñ">ƒƒ“ƒo[ƒvƒƒtƒB[ƒ‹</a></li>
<li id="salonSearch"><a href="profile_shop.php" title="ƒƒjƒ…[“o˜^">ƒVƒ‡ƒbƒvî•ñ</a></li>
<li id="hairStyle"><a href="profile_menu.php" title="ƒCƒxƒ“ƒgî•ñ">ƒƒjƒ…[“o˜^</a></li>
<li id="special"><a href="profile_picture.php" title="ƒwƒAŽÊ^“o˜^">ƒwƒAŽÊ^“o˜^</a></li>
<li id="Sitemap"><a href="profile_coupon.php" title="ƒN[ƒ|ƒ““o˜^">ƒN[ƒ|ƒ““o˜^</a></li>
</ul>
</div>
<div id="footer">
<ul>
<li><a href="profile_event.php">ƒCƒxƒ“ƒgî•ñ</a></li>
<li><a href="profile_mouth.php">ŒûƒRƒ~ƒR[ƒi[</a></li>
<li><a href="mail.html">‚¨–â‚¢‡‚킹</a></li>
<li><a href="../advertisement.html">LŒfÚ‚ɂ‚¢‚Ä</a></li>
<li><a href="beautysalon_oner.html">ƒTƒƒ“ƒI[ƒi—l‚Ö</a></li>
<li><a href="link.html">ƒŠƒ“ƒN‚ɂ‚¢‚Ä</a></li>
</ul>
<address>
Copyright(C) 2006 ”ü—eŽºE”ü—e‰@]“Œ‹žE‘åãE–¼ŒÃ‰®E•Ÿ‰ªEŽD–yŒŸõŒûƒRƒ~ƒTƒCƒg-Stock All Rights Reserved.
</address>
<!--end div#footer-->
</div>

</div>

</body>
</html>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Website Membership: How to Remove "Error Checking"

By yusuke - September 9, 2010

Hi Jason,

Thank you so much!
It's perfect!