Jump to content

Recommended Posts

Hi there, im hoping for abit of advice please...

 

Im have a form on a page that on update directs users to same page! Aprt of the info the user is inputting is form a list/menu...I need to add some sort of vallidation, so that the user cannot enter the same record!! So i need ot make it that what the user has inputted fro list/menu, after update is removed form the list????

 

How would i do this????

 

Thank You

Link to comment
https://forums.phpfreaks.com/topic/90085-listmenu-vallidation/
Share on other sites

Its funny coz i can do the reverse in that i can dislpay records user just enteered on page...i just need to some how query it so that the the query brings up all the records ACCEPT for ones that are displayed - like a paradox :)

 

Any ideas, im stressing :)

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/90085-listmenu-vallidation/#findComment-461882
Share on other sites

Hi there , thnaks for reply!

 

Here is my page of code in full so far:

 <?php require_once('Connections/woodside.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO animalfears (AnimalFearID, AnimalID, FearID) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['animalFearid'], "text"),
                       GetSQLValueString($_POST['animalid'], "int"),
                       GetSQLValueString($_POST['fearid'], "text"));

  mysql_select_db($database_woodside, $woodside);
  $Result1 = mysql_query($insertSQL, $woodside) or die(mysql_error());

  $insertGoTo = "stage3.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_woodside, $woodside);
$query_animal = "SELECT * FROM animal ORDER BY AnimalID DESC";
$animal = mysql_query($query_animal, $woodside) or die(mysql_error());
$row_animal = mysql_fetch_assoc($animal);
$totalRows_animal = mysql_num_rows($animal);

mysql_select_db($database_woodside, $woodside);
$query_animalFear = "SELECT * FROM animalfears";
$animalFear = mysql_query($query_animalFear, $woodside) or die(mysql_error());
$row_animalFear = mysql_fetch_assoc($animalFear);
$totalRows_animalFear = mysql_num_rows($animalFear);

mysql_select_db($database_woodside, $woodside);
$query_fears = "SELECT * FROM fears";
$fears = mysql_query($query_fears, $woodside) or die(mysql_error());
$row_fears = mysql_fetch_assoc($fears);
$totalRows_fears = mysql_num_rows($fears);

mysql_select_db($database_woodside, $woodside);
$query_animalFear2 = "SELECT FearID FROM animalfears WHERE AnimalID='" . $row_animalFear['AnimalID'] . "'";
$animalFear2 = mysql_query($query_animalFear2, $woodside) or die(mysql_error());
$row_animalFear2 = mysql_fetch_assoc($animalFear2);
$totalRows_animalFear2 = mysql_num_rows($animalFear2);
?><!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=iso-8859-1" />
<title>Untitled Document</title>
<link href="bordertop.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
  <table height ="225" border="0" align="center">
    <tr valign="baseline">
      <td  height="20" colspan="3" align="right" valign="middle" nowrap="nowrap"> </td>
    </tr>
    <tr valign="baseline">
      <td width="87"  height="20" align="right" valign="middle" nowrap="nowrap"><strong>Animal ID:</strong></td>
      <td width="6" align="right" valign="middle" nowrap="nowrap"> </td>
      <td height="20" width="158"  valign="middle"><?php echo $row_animal['AnimalID']; ?></td>
    </tr>
    <tr valign="baseline">
      <td height="20" align="right" valign="middle" nowrap="nowrap"><strong>Animal Type:</strong></td>
      <td align="right" valign="middle"  nowrap="nowrap"> </td>
      <td height="20" valign="middle"><?php echo $row_animal['AnimalTypeID']; ?></td>
    </tr>
    <tr valign="baseline">
      <td height="20" align="right" valign="middle" nowrap="nowrap"><strong>Name:</strong></td>
      <td align="right" valign="middle" nowrap="nowrap"> </td>
      <td height="20" valign="middle"><label></label>
          <label><?php echo $row_animal['Name']; ?></label></td>
    </tr>
    <tr valign="baseline">
      <td height="25" align="right" valign="middle" nowrap="nowrap"><strong>Breed:</strong></td>
      <td align="right" valign="middle" nowrap="nowrap"> </td>
      <td height="25" valign="middle"><label><?php echo $row_animal['BreedID']; ?></label></td>
    </tr>
    <tr valign="baseline">
      <td height="22" align="right" valign="middle" nowrap="nowrap"><strong>Age:</strong></td>
      <td align="right" valign="middle" nowrap="nowrap"> </td>
      <td height="25" valign="middle"><label><?php echo $row_animal['Age']; ?></label></td>
    </tr>
    <tr valign="baseline">
      <td height="22" align="right" valign="middle" nowrap="nowrap"><strong>Sex:</strong></td>
      <td align="right" valign="middle" nowrap="nowrap"> </td>
      <td height="25" valign="middle"><label><?php echo $row_animal['Sex']; ?></label></td>
    </tr>
    <tr valign="baseline">
      <td height="22" align="right" valign="middle" nowrap="nowrap"><strong>Date:</strong></td>
      <td align="right" valign="middle" nowrap="nowrap"> </td>
      <td height="25" valign="middle"><?php echo $row_animal['Date']; ?></td>
    </tr>
    <tr valign="baseline">
      <td height="25" colspan="3" align="right" valign="middle" nowrap="nowrap"> </td>
    </tr>
  </table>
  <p> </p>
  <table width="471" border="0" align="center">
    <tr>
      <td width="461"> </td>
    </tr>
    <tr>
      <td> </td>
    </tr>
  </table>
  <table width="496" border="0" align="center">
    <tr valign="baseline">
      <td colspan="11" align="right" nowrap="nowrap"><div align="center">
          <p><strong>Animal Experience</strong></p>
        <p> </p>
      </div></td>
    </tr>
    <tr valign="baseline">
      <td width="97" height="30" align="right" valign="baseline" nowrap="nowrap">House Trained:</td>
      <td width="27" valign="baseline"><input <?php if (!(strcmp($row_animal['HouseTrained'],1))) {echo "checked=\"checked\"";} ?> input="input" disabled="disabled" type="checkbox" name="checkbox2" value="checkbox" /></td>
      <td width="7" valign="baseline"> </td>
      <td width="62" valign="baseline">Cats:</td>
      <td width="36" valign="baseline"><input <?php if (!(strcmp($row_animal['ExpCat'],1))) {echo "checked=\"checked\"";} ?> input="input" disabled="disabled" type="checkbox" name="checkbox22" value="checkbox" /></td>
      <td width="15" valign="baseline"> </td>
      <td width="39"> Cars:</td>
      <td width="23" valign="baseline"><input <?php if (!(strcmp($row_animal['ExpCar'],1))) {echo "checked=\"checked\"";} ?> input="input" disabled="disabled" type="checkbox" name="checkbox24" value="checkbox" /></td>
      <td width="9" valign="baseline"> </td>
      <td width="63" valign="baseline">Children:</td>
      <td width="72" valign="baseline"><input <?php if (!(strcmp($row_animal['ExpChild'],1))) {echo "checked=\"checked\"";} ?> input="input" disabled="disabled" type="checkbox" name="checkbox25" value="checkbox" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">On lead:</td>
      <td><input <?php if (!(strcmp($row_animal['ExpOnlead'],1))) {echo "checked=\"checked\"";} ?> input="input" disabled="disabled" type="checkbox" name="checkbox27" value="checkbox" /></td>
      <td> </td>
      <td> Off Lead:</td>
      <td><input <?php if (!(strcmp($row_animal['ExpOffLead'],1))) {echo "checked=\"checked\"";} ?> input="input" disabled="disabled" type="checkbox" name="checkbox" value="checkbox" /></td>
      <td> </td>
      <td>dogs:</td>
      <td><input <?php if (!(strcmp($row_animal['ExpDog'],1))) {echo "checked=\"checked\"";} ?> input="input" disabled="disabled" type="checkbox" name="checkbox23" value="checkbox" /></td>
      <td> </td>
      <td>alone:</td>
      <td><input <?php if (!(strcmp($row_animal['ExpAlone'],1))) {echo "checked=\"checked\"";} ?> input="input" disabled="disabled" type="checkbox" name="checkbox26" value="checkbox" /></td>
    </tr>
    <tr valign="baseline">
      <td colspan="11" align="right" nowrap="nowrap"> </td>
    </tr>
  </table>
  <p> </p>
  <table width="200" border="0" align="center">
    <tr>
      <td align="center"><input name="submit" type="submit" value="Update record" /></td>
    </tr>
  </table>
  <p> </p>
  <table height ="117" border="0" align="center">
    <tr valign="baseline">
      <td  height="20" colspan="3" align="right" valign="middle" nowrap="nowrap"> </td>
    </tr>
    <tr valign="baseline">
      <td width="87"  height="20" align="right" valign="middle" nowrap="nowrap">Fear Name: </td>
      <td width="6" align="right" valign="middle" nowrap="nowrap"> </td>
      <td height="20" width="158"  valign="middle"><label>
        <select name="fearid" id="fearid">
          <?php
do {  
?>
          <option value="<?php echo $row_fears['FearID']?>"><?php echo $row_fears['FearID']?></option>
          <?php
} while ($row_fears = mysql_fetch_assoc($fears));
  $rows = mysql_num_rows($fears);
  if($rows > 0) {
      mysql_data_seek($fears, 0);
  $row_fears = mysql_fetch_assoc($fears);
  }
?>
        </select>
      </label></td>
    </tr>
    <tr valign="baseline">
      <td height="20" align="right" valign="middle" nowrap="nowrap"> </td>
      <td align="right" valign="middle"  nowrap="nowrap"> </td>
      <td height="20" valign="middle"></td>
    </tr>
    <tr valign="baseline">
      <td height="20" align="right" valign="middle" nowrap="nowrap"> </td>
      <td align="right" valign="middle" nowrap="nowrap"> </td>
      <td height="20" valign="middle"><label></label>
          <label></label></td>
    </tr>
    <tr valign="baseline">
      <td height="25" align="right" valign="middle" nowrap="nowrap"> </td>
      <td align="right" valign="middle" nowrap="nowrap"> </td>
      <td height="25" valign="middle"><label></label></td>
    </tr>
  </table>
  <?php do { ?>
    <table width="310" border="1">
      <tr>
        <td width="101">Fear:</td>
        <td width="193"><?php echo $row_animalFear2['FearID']; ?></td>
      </tr>
          </table>
    <?php } while ($row_animalFear2 = mysql_fetch_assoc($animalFear2)); ?><p> </p>
  <p>
    <input name="animalFearid" type="hidden" id="animalFearid" value="<?php echo $totalRows_animalFear +1 ?>" />
    <input name="animalid" type="hidden" id="animalid" value="<?php echo $row_animal['AnimalID']; ?>" />
    <?php echo $totalRows_animalFear ?> </p>
  <p> </p>
    <input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($animal);

mysql_free_result($animalFear);

mysql_free_result($fears);

mysql_free_result($animalFear2);
?>[\code]

I hope this helps???

Link to comment
https://forums.phpfreaks.com/topic/90085-listmenu-vallidation/#findComment-462200
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.