Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3227446
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:34:32+00:00 2026-05-17T16:34:32+00:00

I am using this to compare the password entered and the confirm password. No

  • 0

I am using this to compare the password entered and the confirm password. No matter what, it creates the user. Why so?

here’s the database code –

$connect = @mysql_connect ($host, $username, $password) or die ('error');
$select = @mysql_select_db($db_name, $connect) or die('check');
$username=stripslashes(trim($_POST['username']));
$select_record="select * from users where username=' ".$username."' ";
$select_query=mysql_query($select_record)  or die (mysql_error());
if(mysql_num_rows($select_query)==0)

{
    $fullname = stripslashes(trim($_POST['fullname']));
    $email = stripslashes(trim($_POST['email']));
    $website = stripslashes(trim($_POST['website']));
    $username = stripslashes(trim($_POST['username']));
    $password = stripslashes(trim($_POST['password']));
    $add_new="insert into users (fullname,email,website,username,password) values ('$fullname','$email','$website','$username','$password')";
    $add_query=mysql_query($add_new) or die(mysql_error());
    if($add_query)
    {
        echo "Awesome! You are now a member";
    }
}
else
echo "Please try again";
?>

Above connect, i have my database username and password.

Just to revise, here’s my current code –

<div id="form"><form action="registersuccess.php" method="post">
Full Name<br />
<input type="text" name="fullname"/>
<br /><br />
Website<br />
<input type="text" name="site"/><br /><br />
Email<br />
<input type="text" name="email"/><br /><br />
Username<br />
<input type="text" maxlength="255" name="username"/><br />
<br />
Password<br />
<input type="password" name="password"/><br />
<br />
Confirm Password<br />
<input type="password" name="confirmpass"/><br />
<br />
<p class="submit"><input type="submit" value="Create my Account"/></p>

</form>

<?php
$pass = $_POST['password']; 
$cpass = $_POST['confirmpass'];
$cmp = strcmp($pass, $cpass);

if ($cmp != 0)
{
    echo "check password";
}
else
{
    return true;
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:34:33+00:00Added an answer on May 17, 2026 at 4:34 pm

    A number of glaring syntax gotchas here. It appears that you’re not even seeing any notices/warnings (about undefined variables, undefined constants, etc), so you’d better edit php.ini to turn on error reporting (of at least E_NOTICE or so), or tack this in the beginning of your scripts:

    error_reporting(E_ALL);
    

    That’ll make syntax “errors” (meaning they’re not actual parse errors, but are still typing mistakes that are recognized by PHP to mean something else) much, much easier to catch, as PHP will print messages that tell you if there’s anything fishy with your code, and at which files/lines.

    Now on to the actual issues with your code.


    You need to assign the result of strcmp() to a variable then check that variable. Also, you can change the if condition to say $cmp != 0 since you’re testing for any kind of inequality, that is, you’re testing for is not 0.

    $cmp = strcmp($pass, $cpass);
    
    if ($cmp != 0)
    ...
    

    In fact, by doing that you can completely bypass having to use a temporary variable, and just pass the result of the function call into the condition statement:

    if (strcmp($pass, $cpass) != 0)
    

    Or by directly comparing the strings instead of comparing the strcmp() result:

    if ($pass != $cpass)
    

    Additionally, as others point out, you got your POST value assignments wrong, they should be the other way around, otherwise you’re overwriting $_POST‘s values with nothing. You can also drop the parentheses ( ) for array keys as they’re not necessary at all:

    $pass = $_POST['password']; 
    $cpass = $_POST['confirmpass']; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using this compare options to sort a list of strings: [self compare:aString
Using this code, i am able to send a notification to my own device.
Using this piece of code in the head of a page: <script type=text/javascript> function
Using this standard code: NSMutableDictionary *params = [NSMutableDictionary dictionary]; [params setObject:image forKey:@photo]; [params setObject:text
I have to compare a user entered date, Dt (in mm/dd/yyyy format) with the
I created a Alertview with login and password field. If the user entered the
I am using this code to encryp/decrypt strings between c# and php: class encryption
Im using MVC3 architecture, c#.net. I need to compare text box content(User ID) with
here's my problem: User inputs a password in the Options section of the program.
My user have a password field such as 0!ZWQ2 saved in the database. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.