Hi everybody...
I want to enter values to db like the following,,,
Format is like this (810605-14-6356)
This is the rite format, No a to z letters...
6 digits then - then 2 digits then - then 4 digits. -
dbConnect('db');
-
-
$ic = $_POST['icnumber'];
-
-
if (preg_match('#^[0-9]{6}-[0-9]{2}-[0-9]{4}$#', $ic)) {
-
//$ic is valid
-
error ('IC Number is not in right format.\\n'.
-
'Please enter IC Number agian.');
-
}
-
-
if ($ic==''
-
or $_POST['cicnumber']=='' ) {
-
error ('One or more required fields were left blank.\\n'.
-
'Please fill them in and try again.');
-
}
-
// this makes sure both passwords entered match
-
if ($ic != $_POST['cicnumber']) {
-
error ('Your IC Numbers not matched.\\n'.
-
'Please try again.');
-
}
-
-
// Check for existing user with the ic number
-
$sql = "SELECT COUNT(*) FROM m_users WHERE icnumber = $ic ";
-
$result = mysql_query($sql);
-
if (!$result) {
-
error('A database error occurred in processing your '.
-
'submission.\\nIf this error persists, please '.
-
'contact you@example.com.');
-
}
-
-
if (mysql_result($result,0,0)>0) {
-
error('A user already exists with your chosen IC Number.\\n'.
-
'Please try your own IC Number.');
-
}
-
-
-
$random = rand(1000000,9999999990);
-
-
-
$sql = "INSERT INTO m_users SET
-
icnumber = ('$ic'),
-
acccode = ('$random'),
-
actdate = curdate(),
-
expdate = DATE_ADD(curdate(), INTERVAL 1 month);
-
";
-
if (!mysql_query($sql))
-
error('A database error occurred in processing your '.
-
'submission.\\nIf this error persists, please '.
-
'contact admin@straight-a.com.my .\\n' . mysql_error());
-
-
?>
-
I make this code for it,, but its not working can anyone help me... -
$ic = $_POST['icnumber'];
-
-
if (preg_match('#^[0-9]{6}-[0-9]{2}-[0-9]{4}$#', $ic)) {
-
//$ic is valid
-
error ('IC Number is not in right format.\\n'.
-
'Please enter IC Number agian.');
-
}
-
Thanks in advance.
8 1929
Have you thought about creating three different fields in your MySQL table then in regards to the form separate it with three different fields. This way it will be able to read all the numbers simply without complicated code.
Special chars, when taken literally, must be escaped. You must escape the hyphens in your pattern with a backslash. Like - [0-9]{6}\-[0-9]{2}\-[0-9]{4}
Ronald :cool:
Thanks Ronald the problem is not solved with that.
i dont know why....
Plz help me out of this prob.
Thanks...
I did not show the full expression, just a sample of using literals. Here is the full test[php]if (preg_match('^\ d{6}\-\d{2}\-\d{4}$^', $test)) {
echo "Matched on $test<br />";
}
else {
echo "Failed match on $test<br />";
}[/php]
Ronald :cool:
Thanks Ronald For reply have a great 2007.
I am now far away From my PC.
i will test it later..
But u use \d except of [0-9] ,, it will work..
I dont want to echo if the icnumber format is correct but if
wrong then error(i have common.php in which i call error mag), not echo..
Thanks again for ur help..
It is just a working sample to show you how to test it.You can adapt it to your heart's delight.
Ronald :cool:
Thanks Ronald for help..
I will test this, if any problem i will post reply...
Thanks
Thanks Ronlad for ur help.
i make some changes in it.. and now it is working.. -
if (preg_match('#^[0-9]{6}-[0-9]{2}-[0-9]{4}$#', $ic)) {
-
-
}
-
else {
-
error('IC Number format is not Valid.\\n'.
-
'Please try again.');
-
}
-
Thanks again for ur kind work on this prob... Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Garp |
last post by:
Everyone,
I know there's no comp.databases.mysql group, but if there's the demand for
questions about phrasing queries and the like that aren't PHP related (and
there is - every other q. seems to be), why isn't one created? I haven't
done that for a while, but why hasn't this already been done?
Garp
|
by: Jeroen |
last post by:
I am developing an asp.net website with windows
authentification and I want to check to which group the
user belongs. I know how to check for the user that has
logged in and to see if he belongs to a group that was
predefined by windows but I need to know all the groups
he belongs to (also the ones that I created myself).
Please help me with this, I'm going crazy !
Thanks,
|
by: Jake |
last post by:
Hello,
I am developing an application and there is a specific area in which I
want a specific group of windows users to access only. The users belong to a
group called Security1. How can I test to see if a user belongs to this
group and if so enable the button? Thanks in advance.
Jake
|
by: Rich |
last post by:
The procedure below checks if a character entered into a cell of a
datagridview is contained in a string array of valid characters for this
particular cell. It seems kludgy. I am asking what the best practice would
be. I was thinking I could use an arrayList which has the "contains"
property and do this:
If not arr.Contains(s1) then --- don't continue
but my list of codes might be about 50 char combinations. So I was thinking
a...
|
by: JasonC |
last post by:
Hi,
First time posting here so please be gentle!
I wish to check a variable for a number of words that are in a array.
Not sure if this is the best way to do it, but this is what i have.
I have my own counter system that counts every visitor, but some of these visits are from BOTS, spiders..
| |
by: rote |
last post by:
My sceanrio is this on an asp.net 2.0 freamework.
I want to use any of the data controls e.g Gridview,DetailView etc..
But i want some buttons e.g update,edit save etc to be enable or disabled
based on if they belong to some security groups in active
directory.
I'm looking for the best options for this because i want to store those
security groups somewhere and then check for the
user against those security groups for their authorisation...
|
by: wswilson |
last post by:
In python, I could write:
a = 1
if a in :
do something...
In c (and many other languages):
|
by: marioliveira |
last post by:
I have a orm built with RSForms Pro in which there is a calendar. The form is about bookings for activities, some of which are not available every weekday. Is there a way of checking the date the clients chooses and display some kind of alert in case the activity he/hse is booking, does not take place in that weekday?
|
by: doma23 |
last post by:
This thread was taken from a post in Nz function not working and refers to comments in post #4.
Yeah, I was thinking if you could share that API function you have, because I was searching for a way to verify the user's win password in access for some time now.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |