Jump to content

Can't send "0" to dbase table through my form fields, other numbers & text works


ed01

Recommended Posts

User entries into my form fields will not be accepted if the entry is "0" (zero). Text is fine and numbers are fine but zero is not accepted. My html form is using "text"  ie: <td colspan="3"><input type="text" name="mountainfcscore"  size="5" value="<? echo $mountainfcscore; ?>" /> <? echo $err_mountainfcscore; ?></td> 

and for my phpMyAdmin table I've tried field types "int", "char" and "varchar" yet it will not write "0" to the table. I can manually enter "0" but not thru the form.

Does anyone know what this could be?

Thanks

Ed

Link to comment
Share on other sites

<?php // Turn on output buffering

ob_start();

session_start();

?>

<!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"><!-- InstanceBegin template="/Templates/MountainWFCtemplate.dwt" codeOutsideHTMLIsLocked="false" -->

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- InstanceBeginEditable name="doctitle" -->

<title>Mountain FC - Game Report 2010</title>

<!-- InstanceEndEditable -->

<link rel="stylesheet" rev="stylesheet" href="CSS/mountainWFC.css" type="text/css" media="screen" charset="utf-8" />

<link rel="stylesheet" rev="stylesheet" href="CSS/tabmenu.css" type="text/css" media="screen" charset="utf-8" />

<script src="CSS/tabmenu.js" type="text/javascript" language="Javascript1.2" charset="utf-8"></script>

</head>

 

<body background="newlook2008/nettingbackground.gif">

<div id="header"></div>

<!--close header contains top banner -->

 

<div id="container">

  <div id="mainMenu">

  <a class="inactiveMenuItem" style="left: 90px;" id="mainMenuItem1" href="index.htm">home</a>

  <a class="inactiveMenuItem" style="left: 160px;" id="mainMenuItem2" href="#">U12B</a>

  <a class="inactiveMenuItem" style="left: 160px;" id="mainMenuItem3" href="#">U13B</a>

  <a class="inactiveMenuItem" style="left: 215px;" id="mainMenuItem4" href="#">U14B</a>

  <a class="inactiveMenuItem" style="left: 270px;" id="mainMenuItem5" href="#">U15B</a>

  <a class="inactiveMenuItem" style="left: 325px;" id="mainMenuItem6" href="#">U16B</a>

  <a class="inactiveMenuItem" style="left: 380px;" id="mainMenuItem7" href="#">U12G</a> 

  <a class="inactiveMenuItem" style="left: 380px;" id="mainMenuItem8" href="#">U13G</a>

  <a class="inactiveMenuItem" style="left: 435px;" id="mainMenuItem9" href="#">U14G</a>

  <a class="inactiveMenuItem" style="left: 490px;" id="mainMenuItem10" href="#">U15G</a>

  <a class="inactiveMenuItem" style="left: 545px;" id="mainMenuItem11" href="#">U16G</a>

  <a class="inactiveMenuItem" style="left: 600px;" id="mainMenuItem12" href="coaches.htm">coaches</a>

  <a class="inactiveMenuItem" style="left: 655px;" id="mainMenuItem13" href="contacts.htm">contacts</a>

  <a class="activeMenuItem"  style="left: 710px;" id="mainMenuItem14" href="http://supery.uslsoccer.com/scripts/runisa.dll?M2.65846:gp:1376787602.2009:72016+Elements/Display+E+18235+Letter/Display/+A++9386895">fields</a></div>

  <!--close mainMenu -->

<div id="submenu">

<div style="padding-left: 30px; position: static; display: none;" id="submenu_1"> </div>

   

<div style="padding-left: 30px; position: static; display: none;" id="submenu_2">

  <a href="U12Broster.htm">Roster</a> |     

  <a href="U12Bschedule.htm">Schedule</a> |

  <a href="gamereportsU12B.php">Game Reports</a> </div>

     

<div style="padding-left: 50px; position: static; display: none;" id="submenu_3">

  <a href="http://supery.uslsoccer.com/teams/2010/roster/20538126.html" target="_blank">Roster</a> |     

  <a href="http://supery.uslsoccer.com/teams/2010/20538126.html" target="_blank">Schedule</a> |

  <a href="http://supery.uslsoccer.com/schedules/2010/20508671.html" target="_blank">Standings</a> |

  <a href="gamereportsU13B.php">Game Reports</a> </div>

     

<div style="padding-left: 105px; position: static; display: none;" id="submenu_4">

  <a href="http://supery.uslsoccer.com/teams/2010/roster/14865877.html" target="_blank">Roster</a> |     

  <a href="http://supery.uslsoccer.com/teams/2010/14865877.html" target="_blank">Schedule</a> |

  <a href="http://supery.uslsoccer.com/schedules/2010/20508672.html" target="_blank">Standings</a> |

  <a href="gamereportsU14B.php">Game Reports</a> </div>

     

<div style="padding-left: 160px; position: static; display: none;" id="submenu_5">

  <a href="http://supery.uslsoccer.com/teams/2010/roster/9388182.html" target="_blank">Roster</a> |     

  <a href="http://supery.uslsoccer.com/teams/2010/9388182.html" target="_blank">Schedule</a> |

  <a href="http://supery.uslsoccer.com/schedules/2010/20508673.html" target="_blank">Standings</a> |

  <a href="gamereportsU15B.php">Game Reports</a> </div>

     

<div style="padding-left: 215px; position: static; display: none;" id="submenu_6">

  <a href="http://supery.uslsoccer.com/teams/2010/roster/6602006.html" target="_blank">Roster</a> |     

  <a href="http://supery.uslsoccer.com/teams/2010/6602006.html" target="_blank">Schedule</a> |

  <a href="http://supery.uslsoccer.com/schedules/2010/20508674.html" target="_blank">Standings</a> |

  <a href="gamereportsU16B.php">Game Reports</a> </div>

     

<div style="padding-left: 270px; position: static; display: none;" id="submenu_7">

  <a href="U12Groster.htm">Roster</a> |     

  <a href="U12Gschedule.htm">Schedule</a> |

  <a href="gamereportsU12G.php">Game Reports</a> </div> 

     

<div style="padding-left: 325px; position: static; display: none;" id="submenu_8">

  <a href="http://supery.uslsoccer.com/teams/2010/roster/20538156.html" target="_blank">Roster</a> |     

  <a href="http://supery.uslsoccer.com/teams/2010/20538156.html" target="_blank">Schedule</a> |

  <a href="http://supery.uslsoccer.com/schedules/2010/20508724.html" target="_blank">Standings</a> |

  <a href="gamereportsU13G.php">Game Reports</a> </div>

     

<div style="padding-left: 380px; position: static; display: none;" id="submenu_9">

  <a href="http://supery.uslsoccer.com/teams/2010/roster/14865998.html" target="_blank">Roster</a> |     

  <a href="http://supery.uslsoccer.com/teams/2010/14865998.html" target="_blank">Schedule</a> |

  <a href="http://supery.uslsoccer.com/schedules/2010/20508725.html" target="_blank">Standings</a> |

  <a href="gamereportsU14G.php">Game Reports</a> </div>

     

<div style="padding-left: 435px; position: static; display: none;" id="submenu_10">

  <a href="http://supery.uslsoccer.com/teams/2010/roster/9388183.html" target="_blank">Roster</a> |     

  <a href="http://supery.uslsoccer.com/teams/2010/9388183.html" target="_blank">Schedule</a> |

  <a href="http://supery.uslsoccer.com/schedules/2010/20508726.html" target="_blank">Standings</a> |

  <a href="gamereportsU15G.php">Game Reports</a> </div>

     

<div style="padding-left: 490px; position: static; display: none;" id="submenu_11">

  <a href="http://supery.uslsoccer.com/teams/2010/roster/6602007.html" target="_blank">Roster</a> |     

  <a href="http://supery.uslsoccer.com/teams/2010/6602007.html" target="_blank">Schedule</a> |

  <a href="http://supery.uslsoccer.com/schedules/2010/20508727.html" target="_blank">Standings</a> |

  <a href="gamereportsU16G.php">Game Reports</a> </div>   

               

<div style="padding-left: 545px; position: static; display: none;" id="submenu_12"> </div>

<div style="padding-left: 600px; position: static; display: none;" id="submenu_13"> </div>

<div style="padding-left: 655px; position: static; display: none;" id="submenu_14"> </div>    

</div><!--close submenu -->

 

 

<div id="rightColumn">

<div id="date">

<script language=JavaScript>

var now = new Date();

var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

var monNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

document.write(monNames[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear());

</script>

</div><!-- close date -->

<br />

  <div id="searchbox">

    <!-- Google CSE Search Box Begins  -->

<form action="http://www.mountainwfc.ca/searchresults.htm" id="searchbox_006277235729731948122:8aawxadozfc">

  <input type="hidden" name="cx" value="006277235729731948122:8aawxadozfc" />

  <input type="hidden" name="cof" value="FORID:11" />

  <input type="text" name="q" size="19" />

  <input type="submit" name="sa" value="Site Search" />

</form>

<!-- Google CSE Search Box Ends -->

 

 

    <div id="rightColumnRow1">

      <div align="center" class="highlight">

        <p><strong><a href="gallery.htm" class="highlight">Photo Gallery</a></strong></p>

        <p><strong><a href="practiceschedule.htm">Practice Schedule</a> </strong></p>

        <p><strong><a href="forms.htm" class="highlight">Forms</a> </strong></p>

        <p><a href="https://ssl.demosphere.com/72957/" target="_blank"><strong>Register Here</strong></a></p>

        <p><strong><a href="archives.htm" class="highlight">Archives</a> </strong></p>

      </div>

      <div align="center"><a href="http://www.whitecapsfc.com" target="_blank"><img src="newlook2008/whitecapsfc.gif" alt="whitecapsfc" border="0" /></a></div>

  </div>

 

    <div id="rightColumnRow2">

      <div align="center"><a href="http://www.whitecapsfc.com/youth/professionaldevelopment/regionalleaguesupery/" target="_blank"><img src="newlook2008/superYleague.gif" alt="superYleague" width="104" height="107" border="0" /></a></div>

    </div>

    <div id="rightColumnRow2">

      <div align="center"><a href="http://www.bcsoccer.net/bcsa/" target="_blank"><img src="newlook2008/pageLogo.jpg" alt="BC Soccer" width="140" height="116" border="0" /></a></div>

    </div>

 

  </div>

</div><!--close rightColumn -->

<!-- InstanceBeginEditable name="dynamic" -->

<!-- InstanceEndEditable -->

<!--close dynamic_content -->

<!-- InstanceBeginEditable name="content" -->

<div id="content">

<?php // - MountainFCgamereports2010_WORKING

// This is the MountainFC game reports entry page.

if (isset($_SESSION['loggedin'])) {

 

// Check if the form has been submitted.

if ( isset ($_POST['submit'])) {

 

$age_level   = $_POST['age_level'];

$age_level    = $_POST['age_level'];

$opposition     = htmlentities ($_POST['opposition']); // prevents delete of characters following a double quote

$opposition   = stripslashes ($opposition); // removes unsightly slashes

$game_month     = htmlentities ($_POST['game_month']);

$game_month   = stripslashes ($game_month);

$game_day     = htmlentities ($_POST['game_day']);

$game_day     = stripslashes ($game_day);

$location     = htmlentities ($_POST['location']);

$location     = stripslashes ($location);

$weather   = htmlentities ($_POST['weather']);

$weather   = stripslashes ($weather);

$mountainfcscore  = $_POST['mountainfcscore'];

$oppositionscore  = $_POST['oppositionscore'];

$halftimescore   = htmlentities ($_POST['halftimescore']);

$halftimescore   = stripslashes ($halftimescore);

$game_details   = htmlentities ($_POST['game_details']);

$game_details   = stripslashes ($game_details);

$scorer1   = htmlentities ($_POST['scorer1']);

$scorer1   = stripslashes ($scorer1);

 

$scorer2   = htmlentities ($_POST['scorer2']);

$scorer2   = stripslashes ($scorer2);

 

$scorer3   = htmlentities ($_POST['scorer3']);

$scorer3   = stripslashes ($scorer3);

 

$scorer4   = htmlentities ($_POST['scorer4']);

$scorer4   = stripslashes ($scorer4);

 

$scorer5   = htmlentities ($_POST['scorer5']);

$scorer5   = stripslashes ($scorer5);

 

$scorer6   = htmlentities ($_POST['scorer6']);

$scorer6   = stripslashes ($scorer6);

 

$scorer7   = htmlentities ($_POST['scorer7']);

$scorer7   = stripslashes ($scorer7);

 

$scorer8   = htmlentities ($_POST['scorer8']);

$scorer8   = stripslashes ($scorer8);

 

$scorer9   = htmlentities ($_POST['scorer9']);

$scorer9   = stripslashes ($scorer9);

 

 

$assist1_1   = htmlentities ($_POST['assist1_1']); // 2_1 indicates the one who first assisted the second goal

$assist1_1   = stripslashes ($assist1_1);

 

$assist2_1   = htmlentities ($_POST['assist2_1']); // 2_1 indicates the one who first assisted the second goal

$assist2_1   = stripslashes ($assist2_1);

 

$assist3_1   = htmlentities ($_POST['assist3_1']);

$assist3_1   = stripslashes ($assist3_1);

 

$assist4_1   = htmlentities ($_POST['assist4_1']);

$assist4_1   = stripslashes ($assist4_1);

 

$assist5_1   = htmlentities ($_POST['assist5_1']);

$assist5_1   = stripslashes ($assist5_1);

 

$assist6_1   = htmlentities ($_POST['assist6_1']);

$assist6_1   = stripslashes ($assist6_1);

 

$assist7_1   = htmlentities ($_POST['assist7_1']);

$assist7_1   = stripslashes ($assist7_1);

 

$assist8_1   = htmlentities ($_POST['assist8_1']);

$assist8_1   = stripslashes ($assist8_1);

 

$assist9_1   = htmlentities ($_POST['assist9_1']);

$assist9_1   = stripslashes ($assist9_1);

 

 

 

$assist1_2   = htmlentities ($_POST['assist1_2']);

$assist1_2   = stripslashes ($assist1_2);

 

$assist2_2   = htmlentities ($_POST['assist2_2']);

$assist2_2   = stripslashes ($assist2_2);

 

$assist3_2   = htmlentities ($_POST['assist3_2']);

$assist3_2   = stripslashes ($assist3_2);

 

$assist4_2   = htmlentities ($_POST['assist4_2']);

$assist4_2   = stripslashes ($assist4_2);

 

$assist5_2   = htmlentities ($_POST['assist5_2']);

$assist5_2   = stripslashes ($assist5_2);

 

$assist6_2   = htmlentities ($_POST['assist6_2']);

$assist6_2   = stripslashes ($assist6_2);

 

$assist7_2   = htmlentities ($_POST['assist7_2']);

$assist7_2   = stripslashes ($assist7_2);

 

$assist8_2   = htmlentities ($_POST['assist8_2']);

$assist8_2   = stripslashes ($assist8_2);

 

$assist9_2   = htmlentities ($_POST['assist9_2']);

$assist9_2   = stripslashes ($assist9_2);

 

 

 

// Check for each value.

$err_age_level  = (empty($age_level)    ? '<b><font color="#FF0000">Please select the Age & Level</font></b>' : '');

$err_opposition  = (empty($opposition)  ? '<b><font color="#FF0000">Please enter the opposition team name</font></b>' : '');

$err_game_month  = (empty($game_month)    ? '<b><font color="#FF0000">Please select the month</font></b>' : '');

$err_game_day      = (empty($game_day)      ? '<b><font color="#FF0000">Please select the game date</font></b>' : '');

$err_mountainfcscore  = (empty($mountainfcscore) ? '<b><font color="#FF0000">Please enter MountainFC score</font></b>' : '');

$err_oppositionscore  = (empty($oppositionscore) ? '<b><font color="#FF0000">Please enter Oppositions score</font></b>' : '');

$err_submittor  = (empty($submittor) ? '<b><font color="#FF0000">Please enter your initials</font></b>' : '');

 

// no error messages

if (empty($err_age_level) && empty($err_opposition) && empty($err_game_month) && empty($err_game_day) && empty($err_mountainfcscore) && empty($err_oppositionscore) && empty($err_submittor)) {

// if (!$problem)

// If there weren't any problems...

// Add registration to the database.

// Connect and select.

$dbc = @mysql_connect ('xx', 'xx', 'xx') or die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');

$x = @mysql_select_db ('xx') or die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');

 

require ('REQtimestampPT.php');

 

// Define the query.

$query = "INSERT INTO MountainFCgamereports2010_WORKING (game_id, age_level, opposition, game_month, game_day, location, weather, mountainfcscore, oppositionscore, halftimescore, game_details, scorer1, assist1_1, assist1_2, scorer2, assist2_1, assist2_2, scorer3, assist3_1, assist3_2, scorer4, assist4_1, assist4_2, scorer5, assist5_1, assist5_2, scorer6, assist6_1, assist6_2, scorer7, assist7_1, assist7_2, scorer8, assist8_1, assist8_2, scorer9, assist9_1, assist9_2, submittor, date_entered) VALUES (0, '".mysql_real_escape_string($age_level)."', '".mysql_real_escape_string($opposition)."', '".mysql_real_escape_string($game_month)."', '".mysql_real_escape_string($game_day)."', '".mysql_real_escape_string($location)."', '".mysql_real_escape_string($weather)."', '".mysql_real_escape_string($mountainfcscore)."', '".mysql_real_escape_string($oppositionscore)."', '".mysql_real_escape_string($halftimescore)."', '".mysql_real_escape_string($game_details)."', '".mysql_real_escape_string($scorer1)."', '".mysql_real_escape_string($assist1_1)."', '".mysql_real_escape_string($assist1_2)."', '".mysql_real_escape_string($scorer2)."', '".mysql_real_escape_string($assist2_1)."', '".mysql_real_escape_string($assist2_2)."', '".mysql_real_escape_string($scorer3)."', '".mysql_real_escape_string($assist3_1)."', '".mysql_real_escape_string($assist3_2)."', '".mysql_real_escape_string($scorer4)."', '".mysql_real_escape_string($assist4_1)."', '".mysql_real_escape_string($assist4_2)."', '".mysql_real_escape_string($scorer5)."', '".mysql_real_escape_string($assist5_1)."', '".mysql_real_escape_string($assist5_2)."', '".mysql_real_escape_string($scorer6)."', '".mysql_real_escape_string($assist6_1)."', '".mysql_real_escape_string($assist6_2)."', '".mysql_real_escape_string($scorer7)."', '".mysql_real_escape_string($assist7_1)."', '".mysql_real_escape_string($assist7_2)."', '".mysql_real_escape_string($scorer8)."', '".mysql_real_escape_string($assist8_1)."', '".mysql_real_escape_string($assist8_2)."', '".mysql_real_escape_string($scorer9)."', '".mysql_real_escape_string($assist9_1)."', '".mysql_real_escape_string($assist9_2)."', '".mysql_real_escape_string($submittor)."', '$registr_time')";

 

 

 

// Execute the query.

if (@mysql_query ($query)) {

 

//mysql_query("INSERT INTO mytable (product) values ('kossu')");

print '<b>';

printf("New Game Report id %d\n", mysql_insert_id());

$last_record_id = (mysql_insert_id());

//print $last_record_id;

print 'has been sent for approval on ';

print $registr_time;

print '</b>';

 

mysql_close(); // End adding Registration to the database

/*header ('Location: MountainFC_Y_League_EvaluationSignUpReply.htm');*/

print '<font color="#FF0000" size="+1"><p><b>Please do not hit Submit again without first entering new game report information, or click  <a href="http://www.mountainfc.ca/closesession_logout.php">HERE to logout</a></b></p></font>';

 

} else {

print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";

}

 

$link = "http://www.mountainfc.ca/gamereports_APPROVAL_WORKING.php?username=xxxxx&password=xxxxx&game_id=$last_record_id";

$email = 'foucherfamily@shaw.ca';

 

$body="A new game report has been submitted that requires approval.\nPlease click on the following link to open the pending report.\n $link , \n\n\n\n\nNote: this is an automated notification, do not reply to this email";

$headers="From: MountainFC" . "\r\n" ;

 

//mail ($email, 'Game report submitted for approval' , $body, 'From: MountainFC');

mail ($email, 'Game report submitted for approval' , $body, $headers);

}

 

} else {

// default to blank values

$age_level        = '';

$opposition        = '';

$game_month      = '';

$game_day        = '';

$weather            = '';

$mountainfcscore          = '';

$oppositionscore              = '';

$halftimescore          = '';

$game_details            = '';

$scorer1        = '';

$assist1_1        = '';

$assist1_2        = '';

$scorer2  = '';

$assist2_1        = '';

$assist2_2        = '';

$scorer3    = '';

$assist3_1        = '';

$assist3_2        = '';

$scorer4    = '';

$assist4_1        = '';

$assist4_2        = '';

$scorer5    = '';

$assist5_1        = '';

$assist5_2        = '';

$scorer6    = '';

$assist6_1        = '';

$assist6_2        = '';

$scorer7    = '';

$assist7_1        = '';

$assist7_2        = '';

$scorer8    = '';

$assist8_1        = '';

$assist8_2        = '';

$scorer9    = '';

$assist9_1        = '';

$assist9_2        = '';

 

 

 

 

 

// default; no error messages

$err_age_level  = '';

$err_opposition  = '';

$err_game_month  = '';

$err_game_day      = '';

$err_mountainfcscore  = '';

$err_oppositionscore  = '';

$err_submittor  = '';

}

 

// Display the form.

 

// create list of age_level for sticky forms

$age_levelarray = array(

"U12 GIRLS",

"U13 GIRLS",

"U14 GIRLS",

"U15 GIRLS",

"U16 GIRLS",

"U12 BOYS",

"U13 BOYS",

"U14 BOYS",

"U15 BOYS",

"U16 BOYS"

);

foreach($age_levelarray as $key) {

$age_LEVELS .= "<option value=\"$key\"".($age_level == $key ? " selected=\"selected\"" : "").">{$key}</option>\n";

}

if (strpos($age_LEVELS, "selected=")) {

$age_LEVELS = "<option value=\"\">choose</option>\n{$age_LEVELS}";

} else {

$age_LEVELS = "<option value=\"\" selected=\"selected\">choose</option>\n{$age_LEVELS}";

}

 

// create list of game_month for sticky forms

$game_montharray = array(

"May",

"June",

"July",

"August"

);

foreach($game_montharray as $key) {

$game_MONTHS .= "<option value=\"$key\"".($game_month == $key ? " selected=\"selected\"" : "").">{$key}</option>\n";

}

if (strpos($game_MONTHS, "selected=")) {

$game_MONTHS = "<option value=\"\">month</option>\n{$game_MONTHS}";

} else {

$game_MONTHS = "<option value=\"\" selected=\"selected\">month</option>\n{$game_MONTHS}";

}

 

// create list of game_day for sticky forms

$game_dayarray = array(

"1st",

"2nd",

"3rd",

"4th",

"5th",

"6th",

"7th",

"8th",

"9th",

"10th",

"11th",

"12th",

"13th",

"14th",

"15th",

"16th",

"17th",

"18th",

"19th",

"20th",

"21st",

"22nd",

"23rd",

"24th",

"25th",

"26th",

"27th",

"28th",

"29th",

"30th",

"31st"

);

foreach($game_dayarray as $key) {

$game_DAYS .= "<option value=\"$key\"".($game_day == $key ? " selected=\"selected\"" : "").">{$key}</option>\n";

}

if (strpos($game_DAYS, "selected=")) {

$game_DAYS = "<option value=\"\">day</option>\n{$game_DAYS}";

} else {

$game_DAYS = "<option value=\"\" selected=\"selected\">day</option>\n{$game_DAYS}";

}

 

 

 

 

//$positions = '';

 

/*foreach($positionarr as $key) {

$positions .= "<option value=\"$key\"".($position_choice_1 == $key ? " selected=\"selected\"" : "").">{$key}</option>\n";

}

if (strpos($positions, "selected=")) {

$positions = "<option value=\"\">choose</option>\n{$positions}";

} else {

$positions = "<option value=\"\" selected=\"selected\">choose</option>\n{$positions}";

}*/

 

/*<select name="game_day">

  <option value="choose day">Monday</option>

  <option value="mon">Tuesday</option>

  <option value="tues">Wednesday</option>

</select>*/

 

 

 

?>

 

<!--DISPLAY FORM -->

 

  <table width="97%" border="0" cellpadding="10" cellspacing="1" bgcolor="#ffffff">

<tr>

<td colspan="4"><font color="#003399" size="4"><center>

  <strong>MOUNTAIN Y-LEAGUE GAME REPORT</strong>

</center></font>

<center>

  for 2010 season

</center>

        </td>

    </tr>

<tr>

    <td colspan="4"><font size="-2">* These fields are required.</font>

        </td>

    </tr>

<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"><font size="-2"></font>

  <table width="97%" border="0" cellpadding="1" cellspacing="1" bgcolor="#000000">

    <tr bordercolor="#000000">

      <td style="background-color:#cc0033" colspan="4"><div align="center"><font color="#FFFFFF"><strong>GAME REPORT</strong></font></div></td>       

</tr>

<tr bordercolor="#000000">

<td>Age Level *</td>

<td colspan="3"><select name="age_level"><? echo $age_LEVELS; ?></select> <? echo $err_age_level; ?></td> 

</tr>

                   

                    <tr bordercolor="#000000">

<td>Name of opponent * </td>

<td colspan="3"><input type="text" name="opposition"  size="40" value="<? echo $opposition; ?>" /> <? echo $err_opposition; ?></td> 

</tr> 

             

<tr bordercolor="#000000">

<td>Game Date * </td>

<td colspan="3"><select name="game_month"><? echo $game_MONTHS; ?></select> <? echo $err_game_month; ?>

                              <select name="game_day"><? echo $game_DAYS; ?></select> <? echo $err_game_day; ?>

                        </td>

</tr>

<tr bordercolor="#000000">

<td>Location</td>

<td colspan="3"><input type="text" name="location" size="40" value="<? echo $location; ?>" /></td>               

</tr>

                    <tr bordercolor="#000000">

<td>Weather, field conditions </td>

<td colspan="3"><input type="text" name="weather"  size="40" value="<? echo $weather; ?>" /></td>         

                    </tr>

                    <tr bordercolor="#000000">

<td>Mountain FC score * </td>

<td colspan="3"><input type="text" name="mountainfcscore"  size="5" value="<? echo $mountainfcscore; ?>" /> <? echo $err_mountainfcscore; ?></td> 

</tr>

                    <tr bordercolor="#000000">

<td>Opposition score * </td>

<td colspan="3"><input type="text" name="oppositionscore"  size="5" value="<? echo $oppositionscore; ?>" /> <? echo $err_oppositionscore; ?></td> 

</tr> 

                    <tr bordercolor="#000000">

<td>Half-time score<br />(mtn:oppos;  ie 2:1)</td>

<td colspan="3"><input type="text" name="halftimescore"  size="5" value="<? echo $halftimescore; ?>" /></td> 

</tr>

                       

<tr bordercolor="#000000">

<td>Game details</td>

<td colspan="3"><textarea name="game_details" cols="60" rows="6"><? echo $game_details; ?></textarea></td>

</tr>

                   

                   

                   

                   

                    <tr bordercolor="#000000">

<td> </td>

<td>Scorer name</td>                   

<td>Assist (first)</td>

<td>Assist (second)</td>                   

</tr>           

                       

                       

                    <tr bordercolor="#000000"> 

                    <td align="right">Goal #1</td>       

<td><input type="text" name="scorer1"  size="20" value="<? echo $scorer1; ?>" />

<td><input type="text" name="assist1_1"  size="20" value="<? echo $assist1_1; ?>" />

<td><input type="text" name="assist1_2"  size="20" value="<? echo $assist1_2; ?>" /> 

</tr> 

                    <tr bordercolor="#000000"> 

                    <td align="right">Goal #2</td>       

<td><input type="text" name="scorer2"  size="20" value="<? echo $scorer2; ?>" />

<td><input type="text" name="assist2_1"  size="20" value="<? echo $assist2_1; ?>" />

<td><input type="text" name="assist2_2"  size="20" value="<? echo $assist2_2; ?>" /> 

</tr> 

                    <tr bordercolor="#000000"> 

                    <td align="right">Goal #3</td>       

<td><input type="text" name="scorer3"  size="20" value="<? echo $scorer3; ?>" />

<td><input type="text" name="assist3_1"  size="20" value="<? echo $assist3_1; ?>" />

<td><input type="text" name="assist3_2"  size="20" value="<? echo $assist3_2; ?>" /> 

</tr>         

                    <tr bordercolor="#000000"> 

                    <td align="right">Goal #4</td>       

<td><input type="text" name="scorer4"  size="20" value="<? echo $scorer4; ?>" />

<td><input type="text" name="assist4_1"  size="20" value="<? echo $assist4_1; ?>" />

<td><input type="text" name="assist4_2"  size="20" value="<? echo $assist4_2; ?>" /> 

</tr>           

                    <tr bordercolor="#000000"> 

                    <td align="right">Goal #5</td>       

<td><input type="text" name="scorer5"  size="20" value="<? echo $scorer5; ?>" />

<td><input type="text" name="assist5_1"  size="20" value="<? echo $assist5_1; ?>" />

<td><input type="text" name="assist5_2"  size="20" value="<? echo $assist5_2; ?>" /> 

</tr> 

                    <tr bordercolor="#000000"> 

                    <td align="right">Goal #6</td>       

<td><input type="text" name="scorer6"  size="20" value="<? echo $scorer6; ?>" />

<td><input type="text" name="assist6_1"  size="20" value="<? echo $assist6_1; ?>" />

<td><input type="text" name="assist6_2"  size="20" value="<? echo $assist6_2; ?>" /> 

</tr> 

                    <tr bordercolor="#000000"> 

                    <td align="right">Goal #7</td>       

<td><input type="text" name="scorer7"  size="20" value="<? echo $scorer7; ?>" />

<td><input type="text" name="assist7_1"  size="20" value="<? echo $assist7_1; ?>" />

<td><input type="text" name="assist7_2"  size="20" value="<? echo $assist7_2; ?>" /> 

</tr>         

                    <tr bordercolor="#000000"> 

                    <td align="right">Goal #8</td>       

<td><input type="text" name="scorer8"  size="20" value="<? echo $scorer8; ?>" />

<td><input type="text" name="assist8_1"  size="20" value="<? echo $assist8_1; ?>" />

<td><input type="text" name="assist8_2"  size="20" value="<? echo $assist8_2; ?>" /> 

</tr>

                    <tr bordercolor="#000000"> 

                    <td align="right">Goal #9</td>       

<td><input type="text" name="scorer9"  size="20" value="<? echo $scorer9; ?>" />

<td><input type="text" name="assist9_1"  size="20" value="<? echo $assist9_1; ?>" />

<td><input type="text" name="assist9_2"  size="20" value="<? echo $assist9_2; ?>" /> 

</tr>   

 

                    <tr bordercolor="#000000">

<td>Initials of Submittor *</td>

<td colspan="3"><input type="text" name="submittor"  size="5" value="<? echo $submittor; ?>" /> <? echo $err_submittor; ?></td>         

                    </tr>

 

<tr bordercolor="#000000">

<td colspan="4">

<div align="left">

<p align="center">

<input type="submit" name="submit" value="Submit for Approval" />

                        <!--<input type="reset" value="Clear form" />-->

                        <!-- upon submit, would like form to clear of its values -->

</p>

</div>

</td>

</tr>

</table>

</form>

</tr></td>

</table>

 

 

<?php

// end if isset SESSION

} else {

 

// Basic HTML formatting stuff.

// Check if the form has been submitted.

if ( isset ($_POST['submit'])) {

 

// Handle the form.

if ( (!empty ($_POST['username'])) && (!empty ($_POST['password'])) ) {

 

if ( ($_POST['username'] == 'xxxxxxx') && ($_POST['password'] == 'xxxxxxx') ) { // Okay.

 

// Do session stuff

$_SESSION['username'] = 'xxxxxxx';

$_SESSION['password'] = 'xxxxxxx';

$_SESSION['loggedin'] = time();

 

// redirect logged in user back to this page

header("Location: {$_SERVER['PHP_SELF']}");

exit();

 

} else { // Not okay.

print '<p>The submitted username and password do not match those on file!<br />Go back and try again.</p>';

}

} else { // Forgot a field.

print '<p>Please make sure you enter both a username and a password!<br />Go back and try again.</p>';

}

} else {

// Basic HTML formatting stuff.

print '<h2>Admin Login Form</h2>

<p>Please enter your User Name and Password.</p>';

 

// Display the form.

print '<form action="MountainFCgamereports2010_WORKING.php" method="post"><p>

Username: <input type="text" name="username" size="20" /><br />

Password:  <input type="password" name="password" size="20" /><br />

<input type="submit" name="submit" value="Log In" /></p>

</form>';

 

} // end else 

}

?> 

</div>

<!--close content -->

<!-- InstanceEndEditable -->

<div id="footer"><a href="index.htm">Home</a> | <a href="mailto:webmaster@mountainwfc.ca">Webmaster</a> | Copyright © 2008-2010. All rights reserved.<br />

</div><!--close footer -->

 

</div><!--close container -->

</body>

<!-- InstanceEnd --></html>

<?php // Turn off output buffering

ob_end_flush();

?>

Link to comment
Share on other sites

The next time someone asks you to post your code, please post only the relevant pieces and put the code between


tags.

 

Your problem is occurring because of the way you are testing for a empty field. Using the empty function is not a good idea since it will return a false positive if the field contains the number zero.

 

I use the following method:

<?php
if (strlen(trim($_POST['field'])) == 0) {
    echo 'Field is empty';
}
?>

 

This short script shows an example:

<?php
if (isset($_POST['submit'])) {
	switch ($_POST['testtype']) {
		case 'empty':
    		if (empty($_POST['test'])) {
    			echo 'Empty';
    		} else {
    			echo 'Field contains ' . $_POST['test'];
    		}
			echo "<br>\n";
			break;
		case 'strlen':
    		if (strlen(trim($_POST['test'])) == 0) {
    			echo 'Empty';
    		} else {
    			echo 'Field contains ' . $_POST['test'];
    		}
			echo "<br>\n";
			break;
	}
}
?>
<html>
<head>
	<title>Test empty field</title>
</head>
<body>
	<form method="post" action="">
		<p>
			<input name="test"><br>
			<input type="radio" name="testtype" value="empty"> Do empty() test<br>
			<input type="radio" name="testtype" value="strlen" selected> Do strlen() test<br>
			<input name="submit" type="submit" value="Do Test">
		</p>
	</form>
</body>
</html>

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.