Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple enough PHP/SQL Question

Guest
May 15, 2007 May 15, 2007
I've made a page where the user signs up to something but I want to prevent them having the same password as their username. Whats the easiest way to do this? Do I do it through dreamweaver or SQL? I assume an IF statement with the conditioon kill or something along those lines will work, I really do not want values with the username and password repeated added to my database at all.

Thanks for the help, sorry it's such a newbie question :P
TOPICS
Server side applications
372
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 16, 2007 May 16, 2007
geschenk wrote:
> you could simply compare the submitted username & password field values using
> an IF-ELSE statement, and if the password equals the username, tell him
> something 😉 What�s your server model, PHP, ASP, CF ?

It says PHP in the subject line, so PHP it is.

if ($_POST) {
if ($_POST['username'] == $_POST['password']) {
$error = '<p>You cannot use your username as the password</p>';
}
else {
// Insert Record server behavior code goes here
}
}

In the form itself:

<?php...
Translate
LEGEND ,
May 15, 2007 May 15, 2007
If, by SQL you mean SQL Server, and depending on what degree of SQL Server
functionality is available to you, then I would do this validation there.
Ideally, the best way to approach this in your database would be to add a
Unique Index accross these two columns, then in your SQL code check for
@@ERROR and build a return value into your code based on what @@ERROR
returns to you.

Hope this helps.


"slowpoke115" <webforumsuser@macromedia.com> wrote in message
news:f2dpub$4bd$1@forums.macromedia.com...
> I've made a page where the user signs up to something but I want to
> prevent
> them having the same password as their username. Whats the easiest way to
> do
> this? Do I do it through dreamweaver or SQL? I assume an IF statement with
> the
> conditioon kill or something along those lines will work, I really do not
> want
> values with the username and password repeated added to my database at
> all.
>
> Thanks for the help, sorry it's such a newbie question :P
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 16, 2007 May 16, 2007
you could simply compare the submitted username & password field values using an IF-ELSE statement, and if the password equals the username, tell him something 😉 What´s your server model, PHP, ASP, CF ?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 16, 2007 May 16, 2007
geschenk wrote:
> you could simply compare the submitted username & password field values using
> an IF-ELSE statement, and if the password equals the username, tell him
> something 😉 What�s your server model, PHP, ASP, CF ?

It says PHP in the subject line, so PHP it is.

if ($_POST) {
if ($_POST['username'] == $_POST['password']) {
$error = '<p>You cannot use your username as the password</p>';
}
else {
// Insert Record server behavior code goes here
}
}

In the form itself:

<?php if (isset($error)) echo $error; ?>

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 16, 2007 May 16, 2007
LATEST
Thanks David, that's basically what I was after, just wasn't sure the right way of doing it. Appreciate the help pal 🙂
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines