Jump to content

Help with $_POST Variable


don4of4

Recommended Posts

For some reason  my code for 47 checkboxes isn't returning anything.  the $_POST variable is the problem, so if you could tell me the correct formating it would be great. $2 dollar reward, just post your email address.

 

 

If ($_POST['stage'] != Null AND $_POST['stage']>=3) {
		echo "stage 3";
		$prow=1;
		$pcol=1;
		while ($prow != 12) 
		{
		echo $_POST["$prow.'_r'.$pcol"];
			If ($_POST["$prow.'_r'.$pcol"] != null)
				{
				$select= "r".$pcol."_data_name";

				$query= mysql_query("SELECT $select WHERE row = $prow");
				echo mysql_result($query);
				}
		if ($pcol == 4) {$pcol=1; $prow = $prow + 1;} else {$pcol = $pcol + 1;}
		}

 

Link to comment
https://forums.phpfreaks.com/topic/205204-help-with-_post-variable/
Share on other sites

Here is all the code:

<?php
include("includes.php");
include("config.php");
$stage=1;
if(isset($_POST['Submit'])) 
{
$fname = strtoupper(mysql_real_escape_string(trim($_POST['fname'])));
$mname = strtoupper(mysql_real_escape_string(trim($_POST['mname'])));
$lname = strtoupper(mysql_real_escape_string(trim($_POST['lname'])));
$sname = strtoupper(mysql_real_escape_string(trim($_POST['sname'])));
if ($fname == null or $mname == null or $lname == null) {$final_report = "ERROR: Enter all parts of your name!";} else {
//validate name
$formatname = trim($lname.', '.$fname.' '.$mname.'. '.$sname);
$check_members = mysql_query("SELECT * FROM `roster` WHERE `name`='$formatname'") or die(mysql_error());   
if (mysql_num_rows($check_members) == 0) {$final_report = "We have no record of your name in our server.  Please check your spelling.";} else {
//end
//Check if already submited
$check_submit = mysql_query("SELECT * FROM `merit` WHERE `name`='$formatname'") or die(mysql_error()); 
if (mysql_num_rows($check_submit) != 0) {$final_report = "We already have merit badges for your name in our server.  To change them <a href='contact.php'>Contact Us</a> or to view, <a href=''>click here</a>.";} else {
//end
$stage=2;
If ($_POST['stage'] != Null AND $_POST['stage']>=2) {
	$num_of_mb = mysql_real_escape_string($_POST['num_of_mb']);
	if ($num_of_mb == null or $num_of_mb =="") {$final_report = "Select # of merit badges!";} else {
	if ($num_of_mb == 1 OR $num_of_mb == 2 OR $num_of_mb == 3 OR $num_of_mb == 4 OR $num_of_mb == 5 OR $num_of_mb == 6 OR $num_of_mb == 7 OR $num_of_mb == 8 OR $num_of_mb == 9) {
	$stage=3;
	//Get Mb's
	$mb_table = mysql_query("SELECT * FROM mbs");
	//end
	If ($_POST['stage'] != Null AND $_POST['stage']>=3) {
		echo "stage 3";
		$prow=1;
		$pcol=1;
		while ($prow != 12) 
		{
		echo $_POST["$prow.'_r'.$pcol"];
			If ($_POST["$prow.'_r'.$pcol"] != null)
				{
				$select= "r".$pcol."_data_name";

				$query= mysql_query("SELECT $select WHERE row = $prow");
				echo mysql_result($query);
				}
		if ($pcol == 4) {$pcol=1; $prow = $prow + 1;} else {$pcol = $pcol + 1;}
		}


	}} else {$final_report= "Invalid # of merit badges.";
}}}}}}}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body> 
<head> 
<title>Troop 542</title> 
<link rel="stylesheet" href="table.css" type="text/css" /> 
</head>
<div id="wrapper">
    <div id="header">

        <a href="index.php">
        <div id="logo">
        </div></a>
        <div id="updates">
        <span> </span>
        </div>
        <div id="login">
        <div id="loginwelcome">
        

            </div>
	</div>
	</div>

            <ul id="navigation">
	    	<li class="on"><a href="index.php<?php echo $referral_string?>">Home</a></li>	    
                <li><a href="help.php<?php echo $referral_string?>">Help</a></li>
                <li><a href="contact.php<?php echo $referral_string?>">Contact Us</a></li>

  			   
            </ul>

<div id="content">
<?php if ($final_report !== null) {echo "<font color='red'><b>".$final_report."</b></font><br><br>"; } ?>

<b>Please enter your formal name:</b><br>  <font color="gray"><i>Nicknames will not work.  Your name must match our records in datascout.</i></font>
<form action="" method="post">
<fieldset style="border:none;">
<table class="stats">
<tr class="stats">
<th class="stats" style="width:35%">First Name</th>
<th class="stats" style="width:15%">M Initial</th>
<th class="stats" style="width:40%">Last Name</th>
<th class="stats" style="width:35%">Suffix</th>
</tr class="stats">

<tr class="stats">
<td class="stats"><input type="text" name="fname" class="item" value="<? echo $fname; ?>" size='30' />
</td>
<td class="stats"><input type="text" name="mname" class="item" value="<? echo $mname; ?>" maxlength="1" size='2' />
</td>
<td class="stats"><input type="text" name="lname" class="item" value="<? echo $lname; ?>" size='30'/>
</td>
<td class="stats"><input type="text" name="sname" class="item" value="<? echo $sname; ?>" size='5' maxlength="5"/>
</td>
</tr>

</table>
<?php if ($stage != 1) { ?>
<br><br>
<p>Number of Merit Badges you wish to signup for: 
<input type="text" name="num_of_mb" class="item" value="<? echo $num_of_mb; ?>" size='1' maxlength="1"/> Merit Badges
</P> <br><br>
<?php } ?>

<?php if ($stage >= 3) { $crow=1; ?>

<center><table>

<?php while($row = mysql_fetch_array($mb_table)) { ?>
<tr class="mbs">
<td class="mbs"><input type="checkbox" name="<?php echo $crow."_r1"?>" value="<?php echo $row['r1_data_name']; ?>"><?php echo $row['r1_name']; ?> </td>
<td class="mbs"><input type="checkbox" name="<?php echo $crow."_r2"?>" value="<?php echo $row['r2_data_name']; ?>"><?php echo $row['r2_name']; ?> </td>
<td class="mbs"><input type="checkbox" name="<?php echo $crow."_r3"?>" value="<?php echo $row['r3_data_name']; ?>"><?php echo $row['r3_name']; ?> </td>
<?php if ($row['r4_name']!=null) { ?><td class="mbs"><input type="checkbox" name="<?php echo $crow."_r4"?>" value="<?php echo $row['r4_data_name']; ?>"><?php echo $row['r4_name']; ?> </td><?php } ?>
</tr>
<?php $crow=$crow+1; } ?>

</table></center>


<?php } ?>

<input type="hidden" name="stage" class="item" value="<? echo $stage; ?>" />
<p><input type="submit" name="Submit" value="Submit" id="signup" style="float:left;border:1px solid #999;background:#E4E4E4;margin-top:5px;" /></p>
</fieldset>
</form>



</div>


<?php include("footer.php");?>		

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.