Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello, i m in need of a php code that creates a form in which we get to enter a phone number that may be from 5-18 digits and when the submit button in form is pressed it should display the nuber with last four digits starred.
EX- if i enter this number 999922233
output shud come lyk 99992****

please help guys i need to submit this within 3 hrs

so far i m here;

<?php
 
 $strPhone = "";
if(isset($_POST['submit'])) {
 

  //assign post data to variables
  $name = trim($_POST['name']);
if (!empty $name) {
    $len = strlen($name);
    $strPhone = substr($strPhone, 0 $len - 4) . "****";
}
 
}// end isset
?>
<!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" />
<meta name="robots" content="noindex, nofollow"/>
<title>Simple PHP Form Demo</title>
 
</head>
<body>
  <div id="contact_form_wrap">
 
    <form id="contact_form" method="post" action=".">
      <p><label>Name:<br />
      <input type="text" name="name" class="textfield" value="<?php echo htmlentities($strPhone); ?>" />
      </label><br /><span class="errors"><?php echo $nameErr; ?></span></p>
 

      <p><input type="submit" name="submit" class="button" value="Submit" /></p>
    </form>
  </div>
 
</body>
</html>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900