PHP Password Validation

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 2173 Views - Last Post: 10 October 2012 - 10:48 AM Rate Topic: -----

#16 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2889
  • View blog
  • Posts: 10,000
  • Joined: 08-August 08

Re: PHP Password Validation

Posted 10 October 2012 - 09:02 AM

In that case you need to write a test, then check to see if it works. When it does, repeat the process until you've got them all working.

I'd start with the preg_match as Jack pointed out.

This post has been edited by CTphpnwb: 10 October 2012 - 09:02 AM

Was This Post Helpful? 0
  • +
  • -

#17 hugoriffic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 185
  • Joined: 16-September 09

Re: PHP Password Validation

Posted 10 October 2012 - 09:16 AM

View PostJackOfAllTrades, on 10 October 2012 - 09:43 AM, said:

Your preg_match regex is wrong. Read the manual page again; you don't have delimiters.

You need to learn to debug, instead of continually returning here with the ever helpful "still not working". Print things! Log things!

JackOfAllTrades,
The preg_match I used was directly copied from the instructor. He did the phone check in class as an example and has a PowerPoint with this exact same structure.
I had a look at this: http://php.net/manua....preg-match.php
and from this line: int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] ) it looks to me as if I've done it properly.
Unless you mean I need to do this:
$PhonePattern = "/\(\d\d\d\) \d\d\d-\d\d\d\d/";


Was This Post Helpful? 0
  • +
  • -

#18 hugoriffic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 185
  • Joined: 16-September 09

Re: PHP Password Validation

Posted 10 October 2012 - 10:21 AM

OK, from my understanding it should be written as such:

if (!preg_match('/^\(\d{3}\) \d{3}\-\d{4}$/') , $Phone))
{
header('location:CreateAccount.htm');
exit();
}
else 
{
$Phone = $_GET['txtPhone'];
}


Does that look better?

This post has been edited by hugoriffic: 10 October 2012 - 10:32 AM

Was This Post Helpful? 0
  • +
  • -

#19 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2889
  • View blog
  • Posts: 10,000
  • Joined: 08-August 08

Re: PHP Password Validation

Posted 10 October 2012 - 10:27 AM

Does it work?

Where's the indenting? You should lose points on any project that doesn't use proper indenting. It also makes reading and therefore debugging more difficult when you don't have it.
Was This Post Helpful? 0
  • +
  • -

#20 hugoriffic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 185
  • Joined: 16-September 09

Re: PHP Password Validation

Posted 10 October 2012 - 10:39 AM

I'm not sure how I lost the indenting. I understand it needs that for more readability. Sorry.
Yes, this seems to work.

One more quick question: Why would the instructor use the line:

$PhonePattern = "\(\d\d\d\) \d\d\d-\d\d\d\d";


when it obviously does not work??
Was This Post Helpful? 0
  • +
  • -

#21 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2889
  • View blog
  • Posts: 10,000
  • Joined: 08-August 08

Re: PHP Password Validation

Posted 10 October 2012 - 10:48 AM

Probably because he wanted to use an example with the intention that you would see that it needed to be changed.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2