PHP - Php And Spry Validation
Does anyone know if you can incorporate PHP forms with Spry validation?
The basic spry text field that validates a number between say 1 and 300 works and is as follows: <script type="text/javascript"> var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "integer", {validateOn:["blur"], isRequired:false, minValue:40,maxValue:}); What I want is the max value to come from a form using PHP. Weirdly I can get it working from a recordset as follows: <script type="text/javascript"> var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "integer", {validateOn:["blur"], isRequired:false, minValue:40,maxValue:<?php echo $row_Recordset4['max']?>}); </script> What I cant get is the value to come from a PHP form as follows. It just doesnt work? <script type="text/javascript"> var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "integer", {validateOn:["blur"], isRequired:false, minValue:40,maxValue:<?php echo $_POST["max"]?>}); </script> Similar TutorialsThis topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=355870.0 Hi, i m new with php programming... I m working on one form in which i have created filter options for filter dynamic table content by completed, approve and rejected status.... but problem is when i m selecting any filtered option using select list data is displayed... but when i m clicking on next button in paging... dynamic table showing blank... same slect list getting blank.... anyone will help me...? code of php file Code: [Select] <?php require_once('../Connections/localhost.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = "client"; $MM_donotCheckaccess = "false"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && false) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "../index.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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; } } $currentPage = $_SERVER["PHP_SELF"]; $maxRows_Recordset1 = 30; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; $myID = $_SESSION['MM_Username']; $mystatus=$_GET['status']; switch ($options) { case "All"; $All="selected"; break; case "Completed"; $Completed="selected"; break; case"Rejected"; $Rejected="selected"; break; case"Pending"; $Pending="selected"; break; } $mystatus=$_POST['status']; $maxRows_Recordset1 = 10; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; //databse queary for filters $query_Recordset1 = "SELECT username, Jobid, Market, General_10, Entry_Points, Dept_Points, General_Points, Total_Points FROM form_gf "; if($mystatus !=='All'){ $query_Recordset1 .= "WHERE status = '$mystatus'";} else { $query_Recordset1 .= "ORDER BY form_gf.Jobid";} mysql_select_db($database_localhost, $localhost); $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $localhost) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; mysql_select_db($database_localhost, $localhost); $query_status = "SELECT dropdown.options FROM dropdown WHERE dropdown.dropdownname = 'status'"; $status = mysql_query($query_status, $localhost) or die(mysql_error()); $row_status = mysql_fetch_assoc($status); $totalRows_status = mysql_num_rows($status);mysql_select_db($database_localhost, $localhost); $query_status = "SELECT options FROM dropdown WHERE dropdownname = 'status' ORDER BY options ASC"; $status = mysql_query($query_status, $localhost) or die(mysql_error()); $row_status = mysql_fetch_assoc($status); $totalRows_status = mysql_num_rows($status); $queryString_Recordset1 = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_Recordset1") == false && stristr($param, "totalRows_Recordset1") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams)); } } $queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1); ?> <!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=utf-8" /> <title>Brakedown Report</title> <link href="../template.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../Menu/js/jquery.js"></script> <script type="text/javascript" src="../Menu/js/interface.js"></script> <script type="text/javascript" src="../Menu/js/fisheye_patched.js"></script> <!--[if lt IE 7]> <style type="text/css"> .dock img { behavior: url(iepngfix.htc) } </style> <![endif]--> <link href="../Menu/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .Header { font-family: "Segoe UI"; font-size: 12px; font-weight: 500; color: #CCC;} .table { font-family: "Segoe UI"; font-size: 10pt; border: 1px solid #000; } .text { font-family: "Segoe UI"; font-size: 10pt; } a { font-family: "Segoe UI"; font-size: 12px; color: #333; font-weight: bold; } a:link { text-decoration: none; } a:visited { text-decoration: none; color: #333; } a:hover { text-decoration: none; color: #36F; } a:active { text-decoration: none; color: #333; } </style> </head> <body> <!--Wrapper Start--> <div id="wrapper"> <!--Header Start--> <div id="header"> <div id="logo"><img src="../images/logo.png" alt="isnlogo" width="64" height="30" align="middle" longdesc="http://www.isngs.com" /></div> <div id="userinfo"> <table width="180" border="0" align="right" cellpadding="0" cellspacing="0"> <tr> <td width="27" height="34"><img src="../images/user.png" width="26" height="30" alt="user" /></td> <td width="77">Sagar Dhande</td> <td width="26"><img src="../images/arrow.png" width="26" height="30" alt="arrow" /></td> </tr> </table> </div> <div id="status"></div> </div> <!--Header end--> <div id="content"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr align="center"> <td width="99%"> <div id="dash3"> <div id="dash3_grid_head">Total Reccords </div> <div id="dash3_grid_cont_back"><br /> <table width="890" border="0" align="center" cellpadding="0" cellspacing="0" class="table"> <tr class="Header"><form action="" method="post"> <td height="55" colspan="3" align="center" valign="middle" id="filters">Filter By Status</td> <td align="left" valign="middle"><select name="status" id="status2" onchange="document.forms[0].submit();"> <option value="" <?php if (!(strcmp("", $mystatus))) {echo "selected=\"selected\"";} ?>></option> <?php do { ?> <option value="<?php echo $row_status['options']?>"<?php if (!(strcmp($row_status['options'], $mystatus))) {echo "selected=\"selected\"";} ?>><?php echo $row_status['options']?></option> <?php } while ($row_status = mysql_fetch_assoc($status)); $rows = mysql_num_rows($status); if($rows > 0) { mysql_data_seek($status, 0); $row_status = mysql_fetch_assoc($status); } ?> </select></td> <td align="left" valign="bottom"><a href="excel.php"></a></td> <td align="left" valign="bottom"> </td> <td align="center" valign="middle"><a href="../excelexprt.php"></a></td> <td align="center" valign="middle"> </td> <td align="center" valign="middle"> </td> <td align="right" valign="middle"><a href="excel.php"><img src="../images/Export.png" alt="Export" width="48" height="48" border="0" /></a></td> </form> </tr> <tr class="Header"> <td height="2" colspan="10" align="center" valign="bottom" id="filters3"><hr color="#333333" size="1px"/></td> </tr> <tr class="Header"> <td height="345" colspan="10" align="center" valign="bottom" id="filters"><a href="../excelexprt.php"> <iframe src="pai1.php" width="485px" height="370px" frameborder="0"></iframe> </a></td> </tr> <tr class="Header"> <td height="22" colspan="3" align="center" valign="bottom" id="filters2"> </td> <td align="left" valign="bottom"> </td> <td align="left" valign="bottom"> </td> <td align="left" valign="bottom"> </td> <td colspan="4" align="center" valign="middle"> </td> </tr> <tr class="Header"> <td style="border: 1px solid #000;" height="44" colspan="3" align="center" valign="middle" bgcolor="#666666">Options</td> <td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666" class="Header">Job ID</td> <td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">Market ID</td> <td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">Transaction No.</td> <td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">Entry Points</td> <td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">Department Points</td> <td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">General Points</td> <td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">Total Points</td> </tr> <?php do { ?> <tr> <td width="31" height="28" align="center" style="border: 1px solid #000;"><a href="../pdf.php?Jobid=<?php echo $row_Recordset1['Jobid']; ?>" target="_blank"><img src="../images/pdf.png" alt="PDF Export" width="16" height="16" border="0" /></a></td> <td width="31" style="border: 1px solid #000;" align="center"><a href="../view.php?Jobid=<?php echo $row_Recordset1['Jobid']; ?>" target="_blank"><img src="../images/preview.png" alt="Preview" width="16" height="16" border="0" /></a></td> <td width="31" style="border: 1px solid #000;" align="center"><a href="../update_form.php?Jobid=<?php echo $row_Recordset1['Jobid']; ?>" target="_blank"><img src="../images/Edit.png" alt="Edit" width="16" height="16" border="0" /></a></td> <td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['Jobid']; ?> </td> <td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['Market']; ?> </td> <td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['General_10']; ?> </td> <td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['Entry_Points']; ?> </td> <td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['Dept_Points']; ?> </td> <td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['General_Points']; ?> </td> <td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['Total_Points']; ?> </td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> <table border="0" align="center" width="270px"> <tr> <td width="30px" valign="middle"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>"><img src="../images/first.png" alt="First" width="16" height="16" alt="First Page" /> </a> <?php } // Show if not first page ?></td> <td width="30px" valign="middle"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>"><img src="../images/previous.png" alt="Previous Page" width="16" height="16" alt="previous" /> </a> <?php } // Show if not first page ?></td> <td width="150px" style="font-family:'Segoe UI'; font-size:12px; color:#333; font-weight:700; line-height:40px;"> Records <?php echo ($startRow_Recordset1 + 1) ?> to <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> of <?php echo $totalRows_Recordset1 ?></td> <td width="30px" valign="middle"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>"><img src="../images/Next.png" width="16" height="16" alt="Next" /> </a> <?php } // Show if not last page ?></td> <td width="30px" valign="middle"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>"><img src="../images/Last.png" alt="Last Page" width="16" height="16" alt="Last" /> </a> <?php } // Show if not last page ?></td> </tr> </table> </table> </div> <div id="dash3_grid_bot"></div> </div><br /> <br /> <br /> </td> </tr> </table> <div id="dashboard"> </div> </div> <div class="dock" id="dock2"> <div class="dock-container2"> <a class="dock-item2" href="client.php"><span>Dashboard</span><img src="../Menu/images/Dashboard-.png" alt="home" /></a> <a class="dock-item2" href="brakedown.php"><span>Brakedown Report</span><img src="../Menu/images/brakedown.png" alt="contact" /></a> <a class="dock-item2" href="Compliance.php"><span>Compliance Report</span><img src="../Menu/images/compliance.png" alt="portfolio" /></a> <a class="dock-item2" href="jobstatus.php"><span>Job Status Report</span><img src="../Menu/images/jobstatus.png" alt="music" /></a> <a class="dock-item2" href="reports.php"><span>Reports</span><img src="../Menu/images/charts.png" alt="video" /></a> <a class="dock-item2" href="#"><span>Logout</span><img src="../Menu/images/off.png" alt="history" /></a> </div> </div> <!--Menu End--> </div> <!--Wrapper End--> <!--dock menu JS options --> <script type="text/javascript"> $(document).ready( function() { $('#dock2').Fisheye( { maxWidth: 60, items: 'a', itemsText: 'span', container: '.dock-container2', itemWidth: 40, proximity: 80, alignment : 'left', valign: 'bottom', halign : 'center' } ) } ); </script> </body> </html> <?php mysql_free_result($Recordset1); mysql_free_result($status); ?> Please Help me guys I'm looking for a bit of help introducing some validation into my "contact us" page. I'm looking to make the user have to enter an email address into textbox And something into the Enquiry box. My 2 files are below: contact-us.shtml Code: [Select] <!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=utf-8" /> <title>Byrne Computing Services</title> <link href="styles.css" rel="stylesheet" type="text/css" /> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="inc/jquery.js"></script> <script type="text/javascript" src="inc/easySlider.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#slider").easySlider(); }); </script> </head> <body> <div id="wrapper"> <!--#include file="inc_header.html" --> <!--#include file="inc_scrollingimages.html" --> <div id="boxesholder"> <!--#include file="inc_specials.html" --> <div id="main"> <div id="mainheader"> Contact Us</div> <div id="maincontent2"> <h2>Fill in the form below and we will contact you shortly.</h2> <p><img src="images/binarycode.jpg" alt="Binary Code" width="167" height="600" class="images" /><form id="form1" name="form1" method="post" action="mailer.php?mail=1"> <strong>Name: </strong><br /> <input name="name" type="text" class="formsingle" id="name" /> <br /> <br /> <strong>Email:</strong><br /> <input name="email" type="text" class="formsingle" id="emailaddress" /> <br /> <br /> <strong>Interested in:</strong><br /> <table border="0" cellspacing="0" cellpadding="0" class="table"> <tr> <td class="interestedin"><strong>Computer Repair</strong></td> <td class="interestedin"><strong>Console Repair</strong></td> <td class="interestedin"><strong>Other Services</strong></td> </tr> <tr> <td class="interestedin"> <input name="virusandmalwareremoval" type="checkbox" class="formcheckbox" id="virusandmalwareremoval" value="virusandmalwareremoval" /> <label for="virusandmalwareremoval">Virus and Malware Removal</label> </td> <td class="interestedin"> <input name="xbox360drivereplacement" type="checkbox" class="formcheckbox" id="xbox360drivereplacement" value="xbox360drivereplacement" /> <label for="ps3drivereplacement">Xbox 360 Drive Replacement</label> </td> <td class="interestedin"> <input name="databackup" type="checkbox" class="formcheckbox" id="databackup" value="databackup" /> <label for="databackup">Data Backup</label> </td> </tr> <tr> <td class="interestedin"> <input name="fullservice" type="checkbox" class="formcheckbox" id="fullservice" value="fullservice" /> <label for="fullservice">Full Service</label> </td> <td class="interestedin"> <input name="xbox360laserreplacement" type="checkbox" class="formcheckbox" id="xbox360laserreplacement" value="xbox360laserreplacement" /> <label for="ps3laserreplacement">Xbox 360 Laser Replacement</label> </td> <td class="interestedin"> <input name="websites" type="checkbox" class="formcheckbox" id="websites" value="websites" /> <label for="websites">Web Design</label> </td> </tr> <tr> <td class="interestedin"> <input name="quickfix" type="checkbox" class="formcheckbox" id="quickfix" value="quickfix" /> <label for="quickfix">Quick Fix</label> </td> <td class="interestedin"> <input name="xbox360rrodrepair" type="checkbox" class="formcheckbox" id="xbox360rrodrepair" value="xbox360rrodrepair" /> <label for="ps3ylodrepair">Xbox 360 RROD Repair</label> </td> <td class="interestedin"> <input name="datarecovery" type="checkbox" class="formcheckbox" id="datarecovery" value="datarecovery" /> <label for="datarecovery">Data Recovery</label> </td> </tr> <tr> <td class="interestedin"> <input name="upgrades" type="checkbox" class="formcheckbox" id="upgrades" value="upgrades" /> <label for="upgrades">Upgrades</label> </td> <td class="interestedin"><input name="ps3drivereplacement" type="checkbox" class="formcheckbox" id="ps3drivereplacement" value="ps3drivereplacement" /> <label for="ps3drivereplacement">PS3 Drive Replacement</label></td> <td class="interestedin"> <input name="networkinstallation" type="checkbox" class="formcheckbox" id="networkinstallation" value="networkinstallation" /> <label for="networkinstallation">Network Installation</label> </td> </tr> <tr> <td> </td> <td class="interestedin"><input name="ps3laserreplacement" type="checkbox" class="formcheckbox" id="ps3laserreplacement" value="ps3laserreplacement" /> PS3 <label for="ps3laserreplacement"> Laser Replacement</label></td> <td class="interestedin"> <input name="mobilephoneissues" type="checkbox" class="formcheckbox" id="mobilephoneissues" value="mobilephoneissues" /> <label for="mobilephoneissues">Mobile Phone Issues</label> </td> </tr> <tr> <td> </td> <td class="interestedin"><input name="ps3ylodrepair" type="checkbox" class="formcheckbox" id="ps3ylodrepair" value="ps3ylodrepair" /> <label for="ps3ylodrepair">PS3 YLOD Repair</label></td> <td class="interestedin"> <input name="emailconfiguration" type="checkbox" class="formcheckbox" id="emailconfiguration" value="emailconfiguration" /> <label for="emailconfiguration">Email Configuration</label></td> </tr> </table> <br /> <strong>Enquiry: </strong><br /> <textarea name="enquiry" class="formmulti" id="enquiry"></textarea> <br /> <br /> <input type="submit" name="button" id="button" value="Submit" /> </form> </p> <p><br /> </p> </div> </div> </div> <!--#include file="inc_offers.html" --> <!--#include file="inc_footer.html" --> </body> </html> Mailer.php Code: [Select] <?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } if (isset($_REQUEST['name'])) { $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $enquiry = $_REQUEST['enquiry'] ; if (isset($_REQUEST['virusandmalwareremoval'])){ $virusandmalwareremoval = $_REQUEST['virusandmalwareremoval'] . "\n"; } else { $virusandmalwareremoval = ""; } if (isset($_REQUEST['fullservice'])){ $fullservice = $_REQUEST['fullservice'] . "\n"; } else { $fullservice = ""; } if (isset($_REQUEST['quickfix'])){ $quickfix = $_REQUEST['quickfix'] . "\n"; } else { $quickfix = ""; } if (isset($_REQUEST['upgrades'])){ $upgrades = $_REQUEST['upgrades'] . "\n"; } else { $upgrades = ""; } if (isset($_REQUEST['xbox360drivereplacement'])){ $xbox360drivereplacement = $_REQUEST['xbox360drivereplacement'] . "\n"; } else { $xbox360drivereplacement = ""; } if (isset($_REQUEST['xbox360laserreplacement'])){ $xbox360laserreplacement = $_REQUEST['xbox360laserreplacement'] . "\n"; } else { $xbox360laserreplacement = ""; } if (isset($_REQUEST['xbox360rrodrepair'])){ $xbox360rrodrepair = $_REQUEST['xbox360rrodrepair'] . "\n"; } else { $xbox360rrodrepair = ""; } if (isset($_REQUEST['ps3drivereplacement'])){ $ps3drivereplacement = $_REQUEST['ps3drivereplacement'] . "\n"; } else { $ps3drivereplacement = ""; } if (isset($_REQUEST['ps3laserreplacement'])){ $ps3laserreplacement = $_REQUEST['ps3laserreplacement'] . "\n"; } else { $ps3laserreplacement = ""; } if (isset($_REQUEST['ps3ylodrepair'])){ $ps3ylodrepair = $_REQUEST['ps3ylodrepair'] . "\n"; } else { $ps3ylodrepair = ""; } if (isset($_REQUEST['databackup'])){ $databackup = $_REQUEST['databackup'] . "\n"; } else { $databackup = ""; } if (isset($_REQUEST['websites'])){ $websites = $_REQUEST['websites'] . "\n"; } else { $websites = ""; } if (isset($_REQUEST['datarecovery'])){ $datarecovery = $_REQUEST['datarecovery'] . "\n"; } else { $datarecovery = ""; } if (isset($_REQUEST['networkinstallation'])){ $networkinstallation = $_REQUEST['networkinstallation'] . "\n"; } else { $networkinstallation = ""; } if (isset($_REQUEST['mobilephoneissues'])){ $mobilephoneissues = $_REQUEST['mobilephoneissues'] . "\n"; } else { $mobilephoneissues = ""; } if (isset($_REQUEST['emailconfiguration'])){ $emailconfiguration = $_REQUEST['emailconfiguration'] . "\n"; } else { $emailconfiguration = ""; } if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header( "Location: http://www.parkersmedia.com/byrne" ); } $mailcontent = "Name: ".$name; $mailcontent.= "\n\nEmail: ".$email; $mailcontent.= "\n\nInterested in: \n". $virusandmalwareremoval . $fullservice . $quickfix . $upgrades . $xbox360drivereplacement . $xbox360laserreplacement . $xbox360rrodrepair . $ps3drivereplacement . $ps3laserreplacement . $ps3ylodrepair . $databackup . $websites . $datarecovery . $networkinstallation . $mobilephoneissues . $emailconfiguration; $mailcontent.= "\n\nEnquiry: " . $enquiry; mail( "info@byrnecomputingservices.ie", "Enquiry from Byrne Computing Services", "$mailcontent", "From: $name <$email>" ); } header( "Location: http://www.parkersmedia.com/byrne/thankyou.shtml" ); ?> Any help on this would be great! So Im in the weird place where my age validation is not working, any ideas: $dob = strtotime($_POST['dob']); //855993600 Feb 15th 1997 $age_req = strtotime('-13 year', $dob); //445680000 Feb 15th 1984 $time = time(); //1292007621 if ($time < $age_req){} Chaps, as a beginner developing his first web app in PHP, I have done fairly well.
However, I am struggling when it comes to validation.
I have written different ELSEIF statements as seen below which would actually carry out the validation itself.
// First name must be filled and in correct format. if(empty($FirstName)) { $errFirstName = '<p class="errText"> Please enter a value</p>'; echo $errFirstName; }elseif(!preg_match('/^[a-z]+$/i',$FirstName)){ $errFirstName = '<p class="errText">Name may not start with a dash. Letters, spaces and dashes are accepted.</p>'; echo $errFirstName; }The problem is that I do not know how to make them "pop up" when the user makes a mistake. I have a form in addteam.php seen below: <form action="pushteam.php" method="post"> <p>Team name: <input type="text" name="TeamName" /></p> <p>Description: </p> <p><textarea name="Description" rows="4" cols="50">Add your description here.</textarea></p> <p><input type="submit"/></p> </form>And a pushplayer.php script that pushes it to a mysql database: // Get values from form $TeamName=$_POST['TeamName']; $Description=$_POST['Description']; } // Insert data into database $sql="INSERT INTO Teams(TeamName, Description)VALUES('$TeamName', '$Description')"; $result=mysql_query($sql); //If successful return to success.php else print error if($result){ header( 'Location: success.php'); } else { header( 'Location: failure.php'); }The scripts function properly. I would really appreciate if someone could guide me in the right direction here. Make the error pop up and make sure the data is not input. At the moment, if I add my ELSEIF statements, it will carry on and insert the data anyway and redirect me. Thanks im looking to validate an email address before it gets sent to mysql database currently my code checks if an email address is present and if an email address already exists how do you check to see if an address contains a . and a @ symbol? Code: [Select] if($email == '') { $errmsg_arr[] = 'Email is missing'; $errflag = true; } if($email != '') { $qry = "SELECT * FROM users WHERE email='$email'"; $result = mysql_query($qry); if($result) { if(mysql_num_rows($result) > 0) { $errmsg_arr[] = 'Email address already in use'; $errflag = true; } @mysql_free_result($result); } else { die("Query failed"); } } Thanks in advance Hi, I have a mistmatched tag <messagesss></message> BUT it still displays "Validated XML!" BUT then proceeds to the else that outputs each XML error! here is the XML: Code: [Select] <?xml version="1.0" encoding="utf-8"?> <email> <messagesss> <to> <toFirstName>Tove</toFirstName> <toLastName toType="common" style="swag">Smith</toLastName> </to> <from><fromdd/> <fromFirstName>Jani</fromFirstName> <fromLastName fromType="unique">Dravison</fromLastName> </from> </message> </email> Code: [Select] <?php $dom=new DOMDocument(); $dom->load("emailSimple.xml"); $isValidated=false; $dom->formatOutput = true; $dom->saveXML(); $errors=libxml_get_errors();//Returns array where each XML file line is an elem if(!file_exists("emailSimple.xml")) print "no such file!"; else if(strlen(file_get_contents("emailSimple.xml"))==0) print "File is empty!"; else if($dom) {//IF file exists and has content if(empty($errors)) print "Validated XML!";//isValidated=true so now shred! else { //CHECK if current XML file is Well-formed foreach($errors AS $error) {//FOR EACH ERROR OF CURRENT XML FILE TO CHECK echo "Error Code: ".$error->code."<br />"; echo "Error message: ".$error->message; //Column is the end of the line where error is echo "line".$error->line.", column".$error->column."<br />"; echo "----------------------------------------------<br /><br />"; } } libxml_clear_errors(); } ?> I am really new to using php validation, I think I may be on to what I am looking for but not very sure. I am trying to validate my form fields just incase someone forgets (name, subject, message, and email). Here is what I have so far. I was looking at an example on how to validate a phone number. Code: [Select] <!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=utf-8" /> <title>Contact</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <?php $first_name=$_POST['name']; $email_address=$_POST['email']; $subject=$_POST['subject']; $message=$_POST['text']; if(isset($_GET['submit'])) { if(preg_match("/^\(([ $_GET['email']) != ) { echo "The email field was invalid<BR>"; } else if(isset($_GET['submit'])) { if(preg_match("/^\(([ $_GET['name']) != "") { echo "The name field was invalid<BR>"; } else if(isset($_GET['submit'])) { if(preg_match("/^\(([ $_GET['subject']) != "") { echo "The subject field was invalid<BR>"; } else { mail("myemailaddress@gmail.com","Subject: $subject", $message, "From: $first_name <$email_address>"); echo "Thank you for using our mail form.<br/>"; echo "Your email has been sent."; } ?> </body> </html> I have a form validation script which is written in php.. I want to add a validation (in registration form) that if the desired username contains either admin or owner keyword user will have to change his user name.. I made the following code but it does not work.. if(strpos($user_name, "admin")>=0 || strpos($user_name, "moderator")>=0 || strpos($user_name, "owner")>=0) { $error=$error."You are not allowed to take such Username<br>"; $bool=false; } In this code i am not able to enter any username.. And if i change >= to > then "admin123" username is going to be valid... I am troubled .... help me out guyzzz -pranshu.a.11@gmail.com i am using the following to validate a submission form. when i take this validation script out, the php script works fine, however when i use it it redirects to index.html as if their was an error.... please can somebody help, ive tried and cannot see the problem? $fname = $_POST['firstname']; $lname = $_POST['lastname']; $add1 = $_POST['add1']; $add2 = $_POST['add2']; $city = $_POST['city']; $county = $_POST['county']; $country = $_POST['country']; $postcode = $_POST['postcode']; $email1 = $_POST['email1']; $email2 = $_POST['email2']; $mobile = $_POST['mobile']; $home = $_POST['home']; $time = $_POST['time']; $answer = $_POST['answer']; $job = $_POST['job']; $ip = $_SERVER['REMOTE_ADDR']; // validation $validationOK=true; if (Trim($fname)=="") $validationOK=false; if (Trim($lname)=="") $validationOK=false; if (Trim($add1)=="") $validationOK=false; if (Trim($city)=="") $validationOK=false; if (Trim($county)=="") $validationOK=false; if (Trim($country)=="") $validationOK=false; if (Trim($postcode)=="") $validationOK=false; if (Trim($email1)=="") $validationOK=false; if (Trim($email2)!=="$email1") $validationOK=false; if (Trim($mobile)=="") $validationOK=false; if (Trim($time)=="") $validationOK=false; if (Trim($answer)!=="34") $validationOK=false; if (Trim($job)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">"; exit; } Hi there, I am working on getting my php form validation working. I just learned why mine wasn't working and it was because I had a header(location) in the middle of the html doc. The reason I had it there was because the code I am using is placed where I want the error to show. Here is the code I am using for this part. I only have one field being validated at the moment. Code: [Select] <? session_start(); if ($_POST['submit']) { $_SESSION['City'] = $_POST['City']; $errors = ""; if(!$_SESSION['City']){ $errors = $errors . "Please enter your city<br>"; } if ($errors != "") { echo "Please check the following errors:<br>"; echo $errors; } else { header("Location: nextpage.php"); } } ?> My question is: What way would you reorganize this (scrapy) validation to where I can redirect my user to a new page when there is no error value? The form page submits to itself with POST. Thanks for your help. Hi, Im making a form that contains 3 textboxes.. now i want my textboxes to contain only letters.. i used is_numeric for the validation but when i put' like.. "JUSHIRO1" my code will still accept it. can someone help me make a code that will validate my textbox to only accept letters. and one more.. when the user input in the textbox with a number a popup box will appear. Hello I have a textbox and a input button which will insert a mysql record, however i need to validate that textbox if its empty it shouldnt allow that button to insert any record but show a popup error. my script : <script Language="JavaScript"> function Blank_TextField_Validator() { // Check the value of the element named text_name // from the form named text_form if (frmContact.id.value == "") { // If null display and alert box alert("Please fill in the text field."); // Place the cursor on the field for revision frmContact.id.focus(); // return false to stop further processing return (false); } // If text_name is not null continue processing return (true); } </script>Form : <form name="frmContact" id="frmContact" method="POST" action="index.php" onsubmit="return Blank_TextField_Validator()">however its not validating or showing any error. any help? Edited by sam20e, 11 November 2014 - 10:31 AM. I need to validate first name, last name, street, suburb, postcode, email, status and date of birth. I tried to do this validation but gave me heaps of error and I messed up more. Spoiler if (empty($firstname)) {$errors[] =" First Name Can not be Empty <br> ";} if (empty($lastname)) {$errors[] =" Last Name Can not be Empty <br> ";} if (empty($street)) {$errors[] =" Street Can not be Empty <br> ";} if (empty($suburb)) {$errors[] =" Suburb Can not be Empty <br> ";} if (empty($postcode)) {$errors[] =" Postcode Can not be Empty <br> ";} // elseif (!is_numeric($postcode)) {$errors[] =" Postcode must be numeric ";} elseif(!preg_match("/\^\(\[0\-9\]\{5\}\(\[\-\\s\]\?\[0\-9\]\{4\}\)\?\)\$/", $postcode)) {$errors[] =" Please enter a valid post number <br> ";} if( !preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i", $myemail) ) {$errors[] =" You have entered and invalid email address <br> ";} if (empty($DOB)) {$errors[] =" Date only <br> ";} First off, i have made a validation class using array_diff() to check if there are invalid characters submitted by a user. Some extracts: Code: [Select] $this->chr_alpha_lower=array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); $this->chr_alpha_upper=array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); $this->chr_numeric=array('0','1','2','3','4','5','6','7','8','9'); $this->chr_symbol=array(' ','!','@','#','$','%','&','(',')','[',']','.',',',':',';','\'','"','/','=','\\','-','_','?'); ... // lets say only alpha and numeric characters are allowed $allowed_characters=array(); $allowed_characters=array_merge($allowed_characters,$this->chr_alpha_lower,$this->chr_alpha_upper); $allowed_characters=array_merge($allowed_characters,$this->chr_numeric); $input_split=str_split($this->input); $invalid=array_diff($input_split,$allowed_characters); if(empty($invalid)){ return true; } return false; I have two questions. First, for acsii characters is this method 'full proof' or is there a way for someone to get around this validation script? Second, a new site im developing is going to be built with UTF-8 in mind so people can use the site in their own language. How do i validate UTF-8 user input? I know about mb_strings and sanitizing UTF-8 input using this: Code: [Select] preg_match_all('/([\x09\x0a\x0d\x20-\x7e]'. // ASCII characters '|[\xc2-\xdf][\x80-\xbf]'. // 2-byte (except overly longs) '|\xe0[\xa0-\xbf][\x80-\xbf]'. // 3 byte (except overly longs) '|[\xe1-\xec\xee\xef][\x80-\xbf]{2}'. // 3 byte (except overly longs) '|\xed[\x80-\x9f][\x80-\xbf])+/', // 3 byte (except UTF-16 surrogates) $input, $clean_pieces ); $clean_output = join('?', $clean_pieces[0] ); But how do i know what to filter? Example: a field for the user to input first name English: only alpha characters Other language: ????? Help much appreciated. hey everyone, on my site I have a form, is there any reason I should use php validation vs javascript validation ? thanks Hi all, Im trying to add validation to a form to allow PHP to check before its sends the values to another page for them to be uploaded to a database. The problem i have is that i have taken a, i thought simple PHP validating script off the net and i cant seem to get it to work, its just giving me a blank page. I dont know if the script is outdated, i dont think it is. The script is he Code: [Select] <?php include("validation.php"); ?> <!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=UTF-8" /> <title>Test Area</title> <link rel="stylesheet" href="test.css" type="text/css" media="screen" /> </head> <body> <div id="container"> <h1>Add a Product</h1> <?if(isset($_POST['send'])&amp;amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp;amp;(!validateModel($_POST['model']) || !validatePrice($_POST['price']) || !validateDescription($_POST['description']) ) ):?> <div id="error"> <ul> <?if(!validateModel($_POST['model'])):?> <li><strong>Invalid Name:</strong> We want names with more than 3 letters!</li> <?endif?> <?if(!validatePrice($_POST['price'])):?> <li><strong>Invalid E-mail:</strong> Type a Valid Price!</li> <?endif?> <?if(!validateDescription($_POST['description'])):?> <li><strong>Invalid message:</strong> Type a message with at least with 10 letters</li> <?endif?> </ul> </div> <?elseif(isset($_POST['send'])):?> <div id="error" class="valid"> <ul> <li><strong>Congratulations!</strong> All fields are OK ;)</li> </ul> </div> <?endif?> <form method="post" id="customForm" action="" enctype="multipart/form-data"> <div> <label for="model">Model Number</label> <input id="model" name="model" type="text" /> <span id="modelInfo">Please enter your Product Model Number!</span> </div> <div> <label for="product">Product</label> <select class="products" name="products"> <option value="0">Please select an option below</option> <option value="1">19" LCD TV</option> <option value="2">22" LCD TV</option> <option value="3">26" LCD TV</option> <option value="4">32" LCD TV</option> <option value="5">37" LCD TV</option> <option value="6">42" LCD TV</option> <option value="7">37" Plasma TV</option> <option value="8">42" Plasma TV</option> <option value="9">46" Plasma TV</option> <option value="10">50" Plasma TV</option> <option value="11">54" Plasma TV</option> <option value="12">58" Plasma TV</option> <option value="13">Wall Bracket</option> <option value="14">Home Cinema System</option> <option value="15">Bluray Home Cinema System</option> <option value="16">DVD Recorder</option> <option value="17">DVD Player</option> <option value="18">DVD Portable</option> <option value="">Bluray Recorder</option> <option value="">Bluray Player</option> <option value="">Bluray Portable</option> <option value="">Projector</option> <option value="">37" LCD TV</option> <option value="">42" LCD TV</option> <option value="">Personal Video Recorder (PVR)</option> <option value="">3D Technology</option> <option value="">Upright Cleaner</option> <option value="">Cylinder Cleaner</option> <option value="">DECT Phone</option> <option value="">DECT Answer Phone</option> <option value="">Washing Machines</option> <option value="">Tumble Dryers</option> <option value="">Dishwashers</option> <option value="">Fridge-Freezers</option> <option value="">Freezers</option> <option value="">Refridgerators</option> <option value="">Microwave (Solo)</option> <option value="">Microwave (Grill)</option> <option value="">Microwave Combination</option> <option value="">Kettles</option> <option value="">Toasters</option> <option value="">Irons</option> <option value="">Breadmakers</option> <option value="">Microsystems</option> <option value="">Minisystems</option> <option value="">CD, Radio and Cassette Players</option> <option value="">Pure Radios</option> <option value="">Dimplex Fires</option> <option value="">Convector Heaters</option> <option value="">Fan Heaters</option> <option value="">Mens Shavers/Grooming</option> <option value="">Ladies Shavers/Beauty</option> <option value="">Straighteners</option> <option value="">Epilators</option> <option value="">Stylish Cameras</option> <option value="">Super Zoom Cameras</option> <option value="">SD Camcorders</option> <option value="">HD Camcorders</option> <option value="">HDD Camcorders</option> <option value="">Bluray Discs</option> <option value="">DVD Discs</option> <option value="">Leads</option> <option value="">Mini DV Tapes</option> <option value="">SD/SDHC/SDXC Cards</option> </select> <span id="productInfo">Please choose a Product Title!</span> </div> <div> <label for="price">Price</label> <input id="price" name="price" type="text" /> <span id="priceInfo">Please enter a Price!</span> </div> <div> <label for="photo">Image</label> <input style="font-size:13px;" class="file" name="photo" type="file" /> <span id="photoInfo">Please choose an Image!</span> </div> <div> <label for="message">Description</label> <textarea id="description" name="description" cols="" rows=""></textarea> </div> <div> <input id="send" name="send" type="submit" value="Send" /> </div> </form> </div> </body> </html> This is the validation file: <?php function validateModel($model){ //if it's NOT valid if(strlen($model) < 4) return false; //if it's valid else return true; } function validatePrice($price){ //if it's NOT valid if(strlen($price) < 4) return false; //if it's valid else return true; } function validateDescription($description){ //if it's NOT valid if(strlen($description) < 10) return false; //if it's valid else return true; } ?> I can't spot the problem, any suggestions? I am trying to validate a field to see if its empty or not and using: if(strlen($company)<1){ this works fine but if someone adds a space character it lets is through. Is there a way to catch this? Hi, I am trying to setup a PHP script that will validate an html form. The form and the PHP script are separate from each other. The code that I have was modified from a tutorial on YouTube. The example used there works but as I have began to tailor it to my purpose, it is now broke. I just added one line for validation to simplify troubleshooting. If I find an empty field on the form, I would like to display the error message on the form itself rather than start a new html page with the PHP script. I am not sure if that is possible. Here is my form: http://www.tallfirshoa.com/adform.htm YouTube videos that I was working from. The video's example has the form and PHP combined as one. In my case, I need the form and PHP separate. http://www.youtube.com/watch?v=yuLpSospbBk&feature=search http://www.youtube.com/watch?v=LF5zTWthpn0&feature=search The code works fine if I leave out the validation. As soon as I add if(!$fname), the script becomes broken. I'm guessing that it has something to do with $errorstring and how it works. I am new to PHP and have tried as many things as I can think of but I can't make any forward progress. Thanks for your help! Rob Code: [Select] <html> <h1>Tall Firs Ad Submission</h1> <?php if ($_POST['submit']) { //Get form data $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $displayemail = $_POST['displayemail']; $phone = $_POST['phone']; $category = $_POST['category']; $description = $_POST['description']; //Declare variables $to = "email@gmail.com"; $subject = "Request"; $headers = "From: $email \r\n Reply-To: $email"; } //Setup form validation $errorstring = "" //default value of error string //Begin validation if (!$fname) $errorstring = $errorstring."First Name<br>"; ?> </html> |