Results 1 to 13 of 13

Thread: Password Check [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Password Check [RESOLVED]

    hi all,

    Code:
    <?php
    
    if ($action == "save")
    {
    	
    $result = mysql_query ("INSERT INTO DB_Warriors_Users Values ('','$user_name','$user_email','$user_password','$user_pending_flag','$user_suspended_flag','$user_moderator_flag','$user_admin_flag','$register_code','$user_real_name','$location','$age','$sex','$season_tkt_no')");
    
    ?>
    On my form I have user_password and user_password_confirm

    I have made the about code and after a user clicks the submit button to action "save" the form, I want it to check if the user_password is the same as the user_passowrd_confirm... I guess and if statement.... any ideas?????
    Last edited by kiwis; Apr 3rd, 2004 at 11:46 PM.

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    will this work?
    PHP Code:
    if ($_POST[USER_PASSWORD] == $_POST[USER_PASSOWRD_CONFIRM] && $action == "save")
        {
        
    $result mysql_query ("INSERT INTO DB_Warriors_Users Values  ('','$user_name','$user_email','$user_password','$user_pending_flag','$user_suspended_flag','$user_moderator_flag','$user_admin_flag','$register_code','$user_real_name','$location','$age','$sex','$season_tkt_no')");
        }
    else
        {
        
    //Return to form page with error displayed
        

    Last edited by Acidic; Mar 28th, 2004 at 05:46 PM.
    Have I helped you? Please Rate my posts.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139
    Hmmmmmm

    Code:
    
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta name="Author" content="Bevan Robinson">
    <title>New Zealand Warriors Supporters Website - http://warriors.rleague.com</title>
    </head>
    <!-- 
    A:link, A:visited { text-decoration: none }
    A:hover { COLOR: black; text-decoration: underline } 
    A.B:link, A.B:visited { COLOR: #000000; text-decoration: none }
    A.B:hover { COLOR: black; text-decoration: underline } 
    -->
    </style>
    <body  link="#000000" vlink="#000000">
    <link rel="stylesheet" type="text/css" href="includes/nz.css">
    
    <?php 
    require("includes/header.php"); 
    ?>
    
    <table BORDER="0" CELLPADDING="3" CELLSPACING="0" width="100%">
     <tr>
      <td valign="top" width="120" bgcolor="#e2e2e2">
             
             
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="120" valign="top" bgcolor="#FFFFFF">
      
      
    <?php 
    require("includes/menu.php"); 
    ?>
    
    		         
        </td> 
       <td class="td-whitecell" width="100%" valign="top"> 
       
       <table width='100%' border='0' cellpadding='1' cellspacing='0' bgcolor='#ffffff'>
    	<tr>
    	<td width='100%' class="td-greyborder">
    	
    	 <table width='100%' class="td-whitecell" cellpadding='4' cellspacing='0' border='0'>
         <tr>
          <td align='left' width='100%'>  
    		
    		<table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
          <tr>
            <td class="td-dogscell"><font class="boxtitle">..:: <span lang="en-au">
           MEMBERS SIGN-UP</span> ::..</font></td>       
    	    </tr>	    
          <tr>
    	  <td width="100%" bgcolor="#FFFFFF">
    <font class="maintext">
    
    
    <?php
    mysql_connect (localhost, user, pass);
    mysql_select_db (nz);
    ?>
    
    <?php
    
    if ($_POST[user_password] == $_POST[user_password_confirm] && $action == "save")    
    	{
    	$result = mysql_query ("INSERT INTO DB_Warriors_Users Values('','$user_name','$user_email','$user_password','$user_pending_flag','$user_suspended_flag','$user_moderator_flag','$user_admin_flag','$register_code','$user_real_name','$location','$age','$sex','$season_tkt_no')");
    
    
    
    	
    
    ?>
    
    
    <?php
    
    
    } else {
    
    ?>
    <p>
    </font>
    <font face="Verdana"
    size="1">
    
    
    <form method="POST" action="signup.php?action=save">
      <p>
    <font face="Verdana" size="1" color="#00000">Username:<br><input type="text" name="user_name" size="40" style="border-style: solid; border-width: 1"></font> <br>
    
    <font face="Verdana" size="1" color="#00000">Email:<br> 
    <input type="text" name="user_email" size="40" style="border-style: solid; border-width: 1"></font> <br>
    
    <font face="Verdana" size="1" color="#00000">Password:<br> <input type="password" name="user_password" size="40" style="border-style: solid; border-width: 1"></font><br>
    <font face="Verdana" size="1" color="#00000">Confirm Password:<br> <input type="password" name="user_password_confirm" size="40" style="border-style: solid; border-width: 1"></font><br>
    
    <font face="Verdana" size="1" color="#00000">Name:<br> <input type="text" name="user_real_name" size="40" style="border-style: solid; border-width: 1"></font><br>
    
    <font face="Verdana" size="1" color="#00000">Location:<br> <input type="text" name="location" size="40" style="border-style: solid; border-width: 1"></font><br>
    
    <font face="Verdana" size="1" color="#00000">Age:<br> <input type="text" name="age" size="5" style="border-style: solid; border-width: 1"></font><br>
    
    <font face="Verdana" size="1" color="#00000">Season Ticket Number: <br><input type="text" name="season_tkt_no " size="40" style="border-style: solid; border-width: 1"></font><br>
    
    <font face="Verdana" size="1" color="#00000">Sex:<br></strong></font><font face="Verdana" size="3"><select name="sex">
      	  <option value="Male">Male</option>
      	  <option value="Female">Female</option>
      	
    	</select></font><font face="Verdana" size="2">  	
    	
      	  <br><br>
    
      <input type="submit" value="Register" name="B1"></p>
    </form>
    
    <?php
    
    }
    
    
    ?>
    
    
    
    </font>
    
    	  </td>
    	    </tr>
         </table>
          </font>
    		</td></tr></table>
          </td></tr></table>
            
             <br>    
    
             </td>
                
            </tr>
            
    </table>
        
     </table>
        
    
    <?php 
    require("includes/footer.php"); 
    ?>
    
    </body>
    </html>
    Last edited by kiwis; Mar 26th, 2004 at 06:52 AM.

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    OK, I'm not good enough at PHP to see what's going wrong. I thought it would be a simple IF
    Have I helped you? Please Rate my posts.

  5. #5
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Does your else statement actually do anything? I think you've forgottn the echo command.

    As I said, I'm still not good at PHP.
    Have I helped you? Please Rate my posts.

  6. #6
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    This works..

    PHP Code:
    <?
      if($_POST['user_password'] == $_POST['user_password_confirm']){
        if($action == "save"){
          //insert stuff
        }
      }else{
        echo "Your passwords do not match.\n";
      }
    ?>
    Like Archer? Check out some Sterling Archer quotes.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139
    I've added that mate, still no good.

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta name="Author" content="">
    <title>Supporters Website - http://</title>
    </head>
    <!-- 
    A:link, A:visited { text-decoration: none }
    A:hover { COLOR: black; text-decoration: underline } 
    A.B:link, A.B:visited { COLOR: #000000; text-decoration: none }
    A.B:hover { COLOR: black; text-decoration: underline } 
    -->
    </style>
    <body  link="#000000" vlink="#000000">
    <link rel="stylesheet" type="text/css" href="includes/nz.css">
    
    <?php 
    require("includes/header.php"); 
    ?>
    
    <table BORDER="0" CELLPADDING="3" CELLSPACING="0" width="100%">
     <tr>
      <td valign="top" width="120" bgcolor="#e2e2e2">
             
             
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="120" valign="top" bgcolor="#FFFFFF">
      
    
    <?php 
    require("includes/menu.php"); 
    ?>
    
    		         
        </td> 
       <td class="td-whitecell" width="100%" valign="top"> 
       
       <table width='100%' border='0' cellpadding='1' cellspacing='0' bgcolor='#ffffff'>
    	<tr>
    	<td width='100%' class="td-greyborder">
    	
    	 <table width='100%' class="td-whitecell" cellpadding='4' cellspacing='0' border='0'>
         <tr>
          <td align='left' width='100%'>  
    		
    		<table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
          <tr>
            <td class="td-dogscell"><font class="boxtitle">..:: <span lang="en-au">
           MEMBERS SIGN-UP</span> ::..</font></td>       
    	    </tr>	    
          <tr>
    	  <td width="100%" bgcolor="#FFFFFF">
    <font class="maintext">
    
    
    <?php
    mysql_connect (localhost, user, password);
    mysql_select_db (nz);
    ?>
    
     <? 
      if($_POST['user_password'] == $_POST
    ['user_password_confirm']){ 
        if($action == "save"){
    
    $result = mysql_query ("INSERT INTO DB_Warriors_Users Values('','$user_name','$user_email','$user_password','$user_pending_flag','$user_suspended_flag','$user_moderator_flag','$user_admin_flag','$register_code','$user_real_name','$location','$age','$sex','$season_tkt_no')");
    	
     } 
      }else{ 
        echo "Your passwords do not match.\n"; 
      } 
    ?>
    
    
    
    <?php
    
    
    } else {
    
    ?>
    
    
    
    <p>
    </font>
    <font face="Verdana"
    size="1">
    
    
    <form method="POST" action="signup.php?action=save">
      <p>
    <font face="Verdana" size="1" color="#00000">Username:<br><input type="text" name="user_name" size="40" style="border-style: solid; border-width: 1"></font> <br>
    
    <font face="Verdana" size="1" color="#00000">Email:<br> 
    <input type="text" name="user_email" size="40" style="border-style: solid; border-width: 1"></font> <br>
    
    <font face="Verdana" size="1" color="#00000">Password:<br> <input type="password" name="user_password" size="40" style="border-style: solid; border-width: 1"></font><br>
    <font face="Verdana" size="1" color="#00000">Confirm Password:<br> <input type="password" name="user_password_confirm" size="40" style="border-style: solid; border-width: 1"></font><br>
    
    <font face="Verdana" size="1" color="#00000">Name:<br> <input type="text" name="user_real_name" size="40" style="border-style: solid; border-width: 1"></font><br>
    
    <font face="Verdana" size="1" color="#00000">Location:<br> <input type="text" name="location" size="40" style="border-style: solid; border-width: 1"></font><br>
    
    <font face="Verdana" size="1" color="#00000">Age:<br> <input type="text" name="age" size="5" style="border-style: solid; border-width: 1"></font><br>
    
    <font face="Verdana" size="1" color="#00000">Season Ticket Number: <br><input type="text" name="season_tkt_no " size="40" style="border-style: solid; border-width: 1"></font><br>
    
    <font face="Verdana" size="1" color="#00000">Sex:<br></strong></font><font face="Verdana" size="3"><select name="sex">
      	  <option value="Male">Male</option>
      	  <option value="Female">Female</option>
      	
    	</select></font><font face="Verdana" size="2">  	
    	
      	  <br><br>
    
      <input type="submit" value="Register" name="B1"></p>
    </form>
    
    <?php
    
    }
    
    
    ?>
    
    
    
    </font>
    
    	  </td>
    	    </tr>
         </table>
          </font>
    		</td></tr></table>
          </td></tr></table>
            
             <br>    
    
             </td>
                
            </tr>
            
    </table>
        
     </table>
        
    
    <?php 
    require("includes/footer.php"); 
    ?>
    
    </body>
    </html>

  8. #8
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    is there really all of those line breaks in your code? if so, try cleaning it up or something.. it's a whole lot easier to read for other people.. some of your line breaks are in the middle of variable definitions, so that could also be your problem.

    what error are you getting, if any?

    you have a <?php }else{ ?> where you don't have an IF statement, so that could be your problem.

    edit: I also know that the code I gave you will work correctly, because it's such a simple piece of code.. it's something else in your code that's giving you problems. when you get parse errors, note the line number and post it here or check out that line.. it would help.
    Like Archer? Check out some Sterling Archer quotes.

  9. #9
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    1) What version of PHP do you have?
    2) Is register_globals on or off?
    3) This annoys me to no end and makes me laugh:

    PHP Code:
    <?php
    mysql_connect 
    (localhostuserpassword);
    mysql_select_db (nz);
    ?>

     <? 
      if($_POST['user_password'] == $_POST
    ['user_password_confirm']){ 
        if($action == "save"){

    $result = mysql_query ("INSERT INTO DB_Warriors_Users  Values('','$user_name','$user_email','$user_password','$user_pending_flag','$user_suspended_flag','$
     user_moderator_flag','$user_admin_flag','$register_code','$user_real_name','$location','$age','$sex'
    ,'$season_tkt_no')");
        
        } 
    }else{ 
        echo "Your passwords do not match.\n"; 

    ?>



    <?php


    } else {

    ?>
    It's pointless to open and close like that, unless you have something between them that you ommitted.
    Last edited by The Hobo; Mar 29th, 2004 at 11:41 AM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Is this all FrontPage generated HTML? If so, then I really have a hate for the program, because that's horribly written code. There's no start tag for style, the link tag is in the wrong place, and not to mention all the deprecated HTML.

    You have an unmattched } or } else {, depending on which you want to keep, and your logic for the IF placement is wrong.

    I tried this, and it works:

    PHP Code:
    <html>
    <head>
        <meta http-equiv="Content-Language" content="en-us">
        <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
        <meta name="ProgId" content="FrontPage.Editor.Document">
        <meta name="Author" content="">
        <title>Supporters Website - [url]http://[/url]</title>
        <link rel="stylesheet" type="text/css" href="includes/nz.css">
        <style type="text/css">
            <!-- 
            A:link, A:visited { text-decoration: none }
            A:hover { COLOR: black; text-decoration: underline } 
            A.B:link, A.B:visited { COLOR: #000000; text-decoration: none }
            A.B:hover { COLOR: black; text-decoration: underline } 
            -->
        </style>
    </head>
    <body  link="#000000" vlink="#000000">
        <?php 
            
    require("includes/header.php"); 
        
    ?>

        <table BORDER="0" CELLPADDING="3" CELLSPACING="0" width="100%">
            <tr>
                <td valign="top" width="120" bgcolor="#e2e2e2">
             
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="120" valign="top" bgcolor="#FFFFFF">
                                <?php 
                                    
    require("includes/menu.php"); 
                                
    ?>         
                            </td> 
                            <td class="td-whitecell" width="100%" valign="top"> 
       
       <table width='100%' border='0' cellpadding='1' cellspacing='0' bgcolor='#ffffff'>
        <tr>
        <td width='100%' class="td-greyborder">
        
         <table width='100%' class="td-whitecell" cellpadding='4' cellspacing='0' border='0'>
         <tr>
          <td align='left' width='100%'>  
            
            <table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
          <tr>
            <td class="td-dogscell"><font class="boxtitle">..:: <span lang="en-au">
           MEMBERS SIGN-UP</span> ::..</font></td>       
            </tr>        
          <tr>
          <td width="100%" bgcolor="#FFFFFF">
    <font class="maintext">


    <?php
        mysql_connect 
    (localhostuserpassword);
        
    mysql_select_db (nz);

        if (
    $_POST['action'] == 'save') {
            if(
    $_POST['user_password'] == $_POST
    ['user_password_confirm']){ 

    /*$result = mysql_query ("INSERT INTO DB_Warriors_Users  Values('','$user_name','$user_email','$user_password','$user_pending_flag','$user_suspended_flag','$user_moderator_flag','$user_admin_flag','$register_code','$user_real_name','$location','$age','$sex'
    ,'$season_tkt_no')");
    */
                
    echo "Passwords match.\n";
            } else { 
                echo 
    "Your passwords do not match.\n"
            } 
        } else {
    ?>

    <p>
    </font>
    <font face="Verdana"
    size="1">


    <form method="POST" action="signup.php">
        <input type="hidden" name="action" value="save" />
      <p>
    <font face="Verdana" size="1" color="#00000">Username:<br><input type="text" name="user_name" size="40" style="border-style: solid; border-width: 1"></font> <br>

    <font face="Verdana" size="1" color="#00000">Email:<br> 
    <input type="text" name="user_email" size="40" style="border-style: solid; border-width: 1"></font> <br>

    <font face="Verdana" size="1" color="#00000">Password:<br> <input type="password" name="user_password" size="40" style="border-style: solid; border-width: 1"></font><br>
    <font face="Verdana" size="1" color="#00000">Confirm Password:<br> <input type="password" name="user_password_confirm" size="40" style="border-style: solid; border-width: 1"></font><br>

    <font face="Verdana" size="1" color="#00000">Name:<br> <input type="text" name="user_real_name" size="40" style="border-style: solid; border-width: 1"></font><br>

    <font face="Verdana" size="1" color="#00000">Location:<br> <input type="text" name="location" size="40" style="border-style: solid; border-width: 1"></font><br>

    <font face="Verdana" size="1" color="#00000">Age:<br> <input type="text" name="age" size="5" style="border-style: solid; border-width: 1"></font><br>

    <font face="Verdana" size="1" color="#00000">Season Ticket Number: <br><input type="text" name="season_tkt_no " size="40" style="border-style: solid; border-width: 1"></font><br>

    <font face="Verdana" size="1" color="#00000">Sex:<br></strong></font><font face="Verdana" size="3"><select name="sex">
            <option value="Male">Male</option>
            <option value="Female">Female</option>
          
        </select></font><font face="Verdana" size="2">      
        
            <br><br>

      <input type="submit" value="Register" name="B1"></p>
    </form>

    <?php

    }


    ?>



    </font>

          </td>
            </tr>
         </table>
          </font>
            </td></tr></table>
          </td></tr></table>
            
             <br>    

             </td>
                
            </tr>
           
    </table>
        
     </table>
        

    <?php 
        
    require("includes/footer.php"); 
    ?>

    </body>
    </html>
    You might want to think about learning HTML and dropping FrontPage. Because that's a real big mess.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139
    Thanks mate, the code was a copy and paste effort from about three other pages... I knew it was all over the show, just using it to try get the PHP working right before I fixed the rest.

    the only thing with your code is that it does not add it to the database , any reason why?

  12. #12
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    uhh.. dude, please tell me your joking..

    Uncomment the call to mysql_query() entry.. It also might benefit you if you actually read over your code, and get down the basics of PHP, like if and else statements, comments, and other simple stuff.
    Like Archer? Check out some Sterling Archer quotes.

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Wink

    Oh didn't see that, swwet as :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width