Results 1 to 1 of 1

Thread: pregmatch field for phone email and website

  1. #1
    Join Date
    Sep 2017
    Posts
    16
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default pregmatch field for phone email and website

    i want to add pregmatch field for phone email and website for this validation.
    PHP Code:
    <?php 

    function _ent($val

        return 
    htmlentities($val); 



    function 
    _element($arr,$index

        return isset(
    $arr[$index]) ? $arr[$index] : ''



    $errors = []; 
    $data = []; 
    if (
    $_SERVER["REQUEST_METHOD"] == "POST"

        
    $data array_map('trim',$_POST); 
        
        
         if(
    $data['Phone'] == ''
        { 
            
    $errors['Phone'] = " Phone is required."
        } 
         if(
    $data['Email'] == ''
        { 
            
    $errors['Email'] = " Email is required."
        } 
         if(
    $data['Web'] == ''
        { 
            
    $errors['Web'] = " Company Website is required."
        } 
        
        
        if(empty(
    $errors)) 
        { 
            
    header('location:ok.php'); 
            die; 
        } 

    ?>



    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    </head>

    <body>

    <table width="1200" border="1">
      <tbody>
       <form action="#" method="post">
        <tr>
          <td><input type="text" name="Phone" placeholder="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enter Phone Number" style="height:45px; width:270px; margin-right: 20px; margin-bottom:20px; " value="<?= _ent(_element($data,'Phone')); ?>"> <?= _element($errors,'Phone'); ?></td>
        </tr>
        <tr>
          <td><input type="text" name="Email" placeholder="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enter Your Email" style="height:45px; width:270px; margin-right: 20px; margin-bottom:20px; " value="<?= _ent(_element($data,'Email')); ?>"> <?= _element($errors,'Email'); ?></td>
        </tr>
        <tr>
          <td><input type="text" name="Web" placeholder="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enter Company Website" style="height:45px; width:270px; margin-right: 20px; margin-bottom:20px; " value="<?= _ent(_element($data,'Web')); ?>"> <?= _element($errors,'Web'); ?></td>
        </tr>
        <tr><td><input type="submit" name="submit" value="submit"> </td></tr>
      </tbody>
        </form>
    </table>

    </body>
    </html>
    Last edited by jscheuer1; 10-19-2017 at 07:33 PM. Reason: format code

Similar Threads

  1. pregmatch script for phone number
    By pkrishna42 in forum PHP
    Replies: 3
    Last Post: 10-05-2017, 06:03 PM
  2. Replies: 8
    Last Post: 10-03-2017, 06:48 AM
  3. Replies: 5
    Last Post: 04-10-2017, 05:24 AM
  4. email and phone no using alert box
    By ravi951 in forum JavaScript
    Replies: 0
    Last Post: 10-03-2011, 10:42 AM
  5. sending mms to phone via email
    By davidjmorin in forum Looking for such a script or service
    Replies: 0
    Last Post: 01-04-2008, 10:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •