logo-dw

Go Back   Dreamweaver Club Forums > Dreamweaver forums > Spry
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 09-08-2008, 03:30 AM   #1
Saw
 
Join Date: Sep 2008
Posts: 4
Default Spry text validation on record update form..not working

Hello I am new at all this, hopefully someone can help.
I am on a localhost php mysql setup. I will not be a "live" website so I am not worried about security. I am working on my first ever mysql php dreamweaver project, learning as I go.

I have made a form that creates a record, this form has a date validation spry that I inserted from the spry menu, it works fine. I.E can not create a new record with wrong format date.

I have made a second form to update the record. and this form works great once I learned how to send the url variable correctly..

----When I try to add the same spry text validation to the update form it never works, it will turn the background of the date box yellow as if it wants to validate but thats it.

I have been looking at tutorials and the adobe site and have seen it said that sometimes you have to edit the code by hand after inserting a spry....they didnt say how/what though.

Here is the code (after validation has been added).

I really appreciate any help fixing this form.
Thank you for your time
Saw

Code:
<?php require_once('Connections/Insert.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE litter_num SET Dob=%s, Mother=%s, Father=%s, `Size`=%s, doa=%s WHERE id=%s",
                       GetSQLValueString($_POST['Dob'], "text"),
                       GetSQLValueString($_POST['Mother'], "text"),
                       GetSQLValueString($_POST['Father'], "text"),
                       GetSQLValueString($_POST['Size'], "int"),
                       GetSQLValueString($_POST['doa'], "int"),
                       GetSQLValueString($_POST['id'], "int"));
  mysql_select_db($database_Insert, $Insert);
  $Result1 = mysql_query($updateSQL, $Insert) or die(mysql_error());
  $updateGoTo = "Litter.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
$colname_Recordset1 = "-1";
if (isset($_GET['recordID'])) {
  $colname_Recordset1 = $_GET['recordID'];
}
mysql_select_db($database_Insert, $Insert);
$query_Recordset1 = sprintf("SELECT * FROM litter_num WHERE id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $Insert) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_free_result($Recordset1);
?><script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  <table align="center">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Id:</td>
      <td><?php echo $row_Recordset1['id']; ?></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Dob:</td>
      <td><span id="sprytextfield1">
        <input type="text" name="Dob" value="<?php echo $row_Recordset1['Dob']; ?>" size="32" />
      <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Mother:</td>
      <td><input type="text" name="Mother" value="<?php echo $row_Recordset1['Mother']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Father:</td>
      <td><input type="text" name="Father" value="<?php echo $row_Recordset1['Father']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Size:</td>
      <td><input type="text" name="Size" value="<?php echo htmlentities($row_Recordset1['Size'], ENT_COMPAT, ''); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Doa:</td>
      <td><input type="text" name="doa" value="<?php echo htmlentities($row_Recordset1['doa'], ENT_COMPAT, ''); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td><input type="submit" value="Update record" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1" />
  <input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>" />
</form>
<p>&nbsp;</p>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"dd/mm/yyyy"});
//-->
</script>
Saw is offline   Reply With Quote
Old 09-17-2008, 10:16 PM   #2
Saw
 
Join Date: Sep 2008
Posts: 4
Default

Problem fixed.

Not sure how I just kept remaking the form till it worked
Saw is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:39 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com