Advertisement
Advertisement
| 05.15.2008 at 06:16AM PDT, ID: 23404931 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: |
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!";
}
?>
|