Jump to content

Search the Community

Showing results for tags 'validate'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 5 results

  1. Hi all, I am trying to validate a form, but run into some troubles... Full Name This works up until a space is present then fails, any suggestions? // # Fullname if (isset($_POST["Fullname"])){ $fnop = $_POST["Fullname"]; if (ctype_alpha($fnop)) { echo "</BR>PASSED! : FULLNAME : $fnop"; } else { echo "</BR>FAILED! : FULLNAME : $fnop"; } }; Test case: INPUT: 123456789 | OUTPUT: FAILED; INPUT: ABCD1234 | OUTPUT: FAILED; INPUT: AbCdEfGh | OUTPUT: PASSED; INPUT: AbC<Space>DeF | OUTPUT: FAILED; Phone number This works up until a 0 is in the number and then fails, any suggestions? // # Contact Num if (isset($_POST["Phone"])){ $phoneop = $_POST["Phone"]; if (filter_var($phoneop, FILTER_VALIDATE_INT)) { echo "</BR>PASSED! : PHONE : $phoneop"; } else { echo "</BR>FAILED! : PHONE : $phoneop"; } }; Test case: INPUT: 123456789 | OUTPUT: PASSED; INPUT: ABCD1234 | OUTPUT: FAILED; INPUT: AbCdEfGh | OUTPUT: FAILED; INPUT: 0432666777 | OUTPUT: FAILED; Kind regards and advance thanks.
  2. maideen

    How to validate input data

    Hi. I am new. I don't know how to validate certain data like emai, web site and numeric value. Here is my code which is work fine. Below is my code. Pls Help me add.php <?php include_once '../inc/header.php'; ?> <Script Language="javascript"> function change_action() { var frm_obj=document.getElementById("frm"); frm_obj.action="data.php"; } </Script> <form action="" method="POST" id="frm" > <table class="" align="center" cellpadding="4" cellspacing="1"> <tr> <td><label class="lbl">ID </label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="id" id="id" readonly="" class="txt"></td> </tr> <tr> <td><label class="lbl">Name </label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="name" id="name" class="txt"></td> </tr> <tr> <td><label class="lbl">Address </label></td> <td><label class="lbl">: </label></td> <td><textarea name="address" id="address" class="txt" rows="5" cols="40"></textarea></td> </tr> <tr> <td><label class="lbl">Tel</label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="tel" id="tel" class="txt"></td> </tr> <tr> <td><label class="lbl">Fax</label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="fax" id="fax" class="txt"></td> </tr> <tr> <td><label class="lbl">Email</label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="email" id="email" class="txt"></td> </tr> <tr> <td><label class="lbl">Web site</label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="website" id="website" class="txt"></td> </tr> <tr> <td><label class="lbl">Type</label></td> <td><label class="lbl">: </label></td> <!--<td><input type="text" name="type" id="type" class="txt"></td>--> <td> <SELECT NAME=type id="type"> <OPTION VALUE=0>Choose <?php $sql="SELECT * FROM bk_parameter where type='typcs' order by id"; $result = mysqli_query($con,$sql); while($row = mysqli_fetch_array($result)) { $typename=$row["name"]; echo "<OPTION VALUE=\"$typename\">".$typename.'</option>'; } ?> </SELECT> </td> </tr> <tr> <td></td> <td></td> <td><input type="submit" value="submit" name="submit" class="btn" onclick="change_action()"> <input type="submit" value="back" name="back" class="btn" onclick="change_action()"></td> </tr> </table> </form> <?php include_once '../inc/footer.php'; ?> data.php <?php include_once '../inc/header.php'; //insert into table if (isset($_POST['submit']) && $_POST['submit'] != "" ) { $name = ($_POST["name"]); $address = ($_POST["address"]); $tel = ($_POST["tel"]); $fax = ($_POST["fax"]); $email = ($_POST["email"]); $website = ($_POST["website"]); $type = ($_POST["type"]); try { $sql="INSERT INTO bk_customer (name,address,tel,fax,email,website,type) VALUES ('$name','$address','$tel','$fax','$email','$website','$type')"; $result = mysqli_query($con,$sql) ; header("Location:index.php"); exit(); } catch (Exception $ex) { echo $e->getMessage() . "\n"; file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND); exit(); } } //mysqli_close($con); // update table if (isset($_POST['update']) && $_POST['update'] != "" ) { $id= ($_POST["id"]); $name = ($_POST["name"]); $address = ($_POST["address"]); $tel = ($_POST["tel"]); $fax = ($_POST["fax"]); $email = ($_POST["email"]); $website = ($_POST["website"]); $type = ($_POST["type"]); try { $sql="UPDATE bk_customer SET name='$name',address='$address', tel='$tel',fax='$fax'," . "email='$email', website='$website',type='$type' WHERE id='$id'"; $result = mysqli_query($con,$sql) ; header("Location:index.php"); } catch (Exception $ex) { echo $e->getMessage() . "\n"; file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND); exit(); } } // update record if (isset($_POST['delete']) && $_POST['delete'] != "" ) { $id=$_POST["id"]; try { $sql="DELETE FROM bk_customer WHERE id='$id'"; $result = mysqli_query($con,$sql) ; header("Location:index.php"); } catch (Exception $ex) { echo $e->getMessage() . "\n"; file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND); exit(); } } // back to index.php if (isset($_POST['back']) && $_POST['back'] != "" ) { header("Location:index.php"); }
  3. Hi I'm trying to post and validate a form but it doesn't seem to work and it doean't display any errors Here's the code <?php include("config.php"); session_start(); ?> <?php // define variables and initialize with empty values $rateErr = $comErr = ""; $rating = $comment = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_POST["rating"] == "") { $rateErr = "Rate the app"; } else { $rating= $_POST["rating"]; } if (empty($_POST["comment"])) { $comErr = "Missing"; } else { $comment = $_POST["comment"]; } if ($rateErr == "" && $comErr == "") { try { $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); $con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = "INSERT INTO reviews (rating, content, appID, user) VALUES(:rating, :comment, :appID, :username)"; $stmt = $con->prepare( $sql ); $stmt->bindValue( ":rating", $rating); $stmt->bindValue( ":comment", $comment); $stmt->bindValue( ":appID", $_GET['id']); $stmt->bindValue( ":username", $_SESSION['username']); $stmt->execute(); return "Submitted successfully"; }catch( PDOException $e ) { return $e->getMessage(); } } } ?> <html> <head> </head> <body> <form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <select name="rating"> <option value=""></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> <span class="error"><?php echo $rateErr;?></span> <br /> <textarea rows="4" cols="50" name="comment" value="<?php echo htmlspecialchars($comment);?>"> Enter text here...</textarea> <span class="error"><?php echo $comErr;?></span> <input type="submit" name="submit" value="Submit"> </form> </body> </html>
  4. aHMAD_SQaLli

    best way to validate in PHP

    Hello sorry if the question is not proper / clear. which one of these two ways is better to validate. <?php # using a variable $query = $_POST['query']; $ok = FALSE; if ( $query = 'php' ){ $ok = TRUE;} else { $ok = FALSE;} if ( $ok = TRUE; ){ // more code } # direct way $query = $_POST['query']; if ( $query = 'php' ){ // more code } else { // more codes } ?> Thanks in advance.
  5. dumb2champ

    Input Validation in Jquery/Js

    Hello Guys... I need help about my validate scripts... $(document).ready(function(){ //Validation jQuery.validator.addMethod('validIPurl', function(value) { var ip = '^([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]).([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]).([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5]).([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])$'; var URL = /^(http|https)?:\/\/[a-zA-Z0-9-\.]+\.[a-z]{2,4}/; //HOW TO JOIN AND VALIDATE BOTH VARIABLE IP AND URL???? } }, 'Invalid Address'); //if(/^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i) $(".myfirstform").validate( { rules: { ip: { validIPurl: true } }, ); }, I use jquery.validate javascripts to validate user input.. I also try to create if..else to join IP and URL but the control statement not working Hope you guys can help for the solution...
×

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.