hello. i shall try to explain fully what i am trying to do. page1 contains a form which has a input field called box_add and a checkbox with the name ‘boxes’ and value of ‘Box Retrival’. in page 2 i m trying to create a condition that tests for the value passed from page1. i am however having trouble getting pass the first isset statement of page 2. if i just enter a value it deals with the value correctly in the first part of th statement. but if i try to evaluate using post from form, it dosen’t go to the next else statement.i have attached the code for your help. many thanks
[code=php]page1 form
<label>
<input name=”boxes” type=”radio” value=”New Intake” checked=”checked” />
Intake</label>
<label>
<input type=”radio” name=”boxes” value=”Box Return” />
Return</label>
<label>
<input type=”radio” name=”boxes” value=”Box Retrival” />
Retrive</label>
<br />
<label>
<input type=”radio” name=”boxes” value=”Box Destruction” />
Destruction</label>
<label>
<input type=”radio” name=”boxes” value=”Box Supply” />
Supply</label></fieldset></p>
<p><fieldset><legend><strong>Select Service Level</strong></legend>
<label>
<input name=”service” type=”radio” value=”standard” checked=”checked” />
Standard</label>
<input type=”textfield” name=”box_add[]” size=”25″ multiple=”multiple” id=”box_add” />
———————————————————————-
page2 statement
<?php
if(isset($_POST[‘box_add’]) && sizeof($_POST[‘box_add’]) > 0)
{
// To make sure the user did include the ‘box’
// We will need this variable later on!
$shall_we_proceed = true;
// Here, we will loop each box’s value and query it to check whether exist or not.
// Ofcourse, it might be slower than yours previous posting, whereby using only 1 statement.
// Is up to you to use which algorithm you wish to validate it. ^^
foreach($_POST[‘box_add’] as $val)
{
$sql = “SELECT custref FROM boxes WHERE custref=’$val'”;
$qry = mysql_query($sql) or die(mysql_error());
$nRecords = mysql_num_rows($qry);
if(mysql_num_rows($qry))
{
echo ‘<span style=”font-weight:bold;color: #ff0000;”>’ . ‘That record already exists in the database: ‘ . ‘</span>’ . ‘<span style=”font-weight:bold;color: #000;”>’ . ‘(‘ . $val . ‘)’ . ‘</span>’ . ‘<br />’ . ‘<span style=”font-weight:bold;color: #ff0000;”>’ . ‘Please select another’ . ‘</span>’ . ‘<p />’;
$shall_we_proceed = false;
break; // Quit the loop
}
}
if($shall_we_proceed)
{
// Okay! We can proceed!
echo ‘You have Added ref: ‘ . ‘<span style=”font-weight:bold;color: #000;”>’ . $val . ‘</span>’ . ‘<p />’;
$_SESSION[‘box_add’] = $_POST[‘box_add’];
}
}
else
if(isset($_POST[‘box_add’]) && ($_POST[‘boxes’]) == ‘Box Retrival’ && sizeof($_POST[‘box_add’]) < 0)
{
// To make sure the user did include the ‘box’
// We will need this variable later on!
$shall_we_proceed = true;
// Here, we will loop each box’s value and query it to check whether exist or not.
// Ofcourse, it might be slower than yours previous posting, whereby using only 1 statement.
// Is up to you to use which algorithm you wish to validate it. ^^
foreach($_POST[‘box_add’] as $val)
{
$sql = “SELECT custref FROM boxes WHERE custref=’$val'”;
$qry = mysql_query($sql) or die(mysql_error());
$nRecords = mysql_num_rows($qry);
if(mysql_num_rows($qry))
{
echo ‘<span style=”font-weight:bold;color: #ff0000;”>’ . ‘That record already exists in the database: ‘ . ‘</span>’ . ‘<span style=”font-weight:bold;color: #000;”>’ . ‘(‘ . $val . ‘)’ . ‘</span>’ . ‘<br />’ . ‘<span style=”font-weight:bold;color: #ff0000;”>’ . ‘Please select another’ . ‘</span>’ . ‘<p />’;
$shall_we_proceed = false;
break; // Quit the loop
}
}
if($shall_we_proceed)
{
// Okay! We can proceed!
echo ‘You have Requested ref: ‘ . ‘<span style=”font-weight:bold;color: #000;”>’ . $val . ‘</span>’ . ‘<p />’;
$_SESSION[‘box_add’] = $_POST[‘boxes’];
}
}
else
{
// Error!
echo “hey! please add box!”;
}
?>