Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-02-2003, 12:49 AM   #1 (permalink)
Nitro
Registered User
 
Nitro's Avatar
 
Join Date: Jun 2003
Location: London, England
Posts: 29
Nitro is on a distinguished road
Send a message via AIM to Nitro
Post Coditionals problem

Ok, basicially I am making a script that allows the user to manage settings in their account. To stop it always trying to update each setting, whenever the user only wanted to update one, the script would check to see if the users setting had changed, and if it had, it would check it to see if the data was clean and such, and if it wasnt, it wouldnt try to update it, however now the when the user clicks the update button, nothing happens. Any idea why? And if there is anything that needs to be explained more, please just ask. Here is the script:

PHP Code:
        if ($p == "general"){
            if(
$_GET['s'] == ""){
            echo
"
            <b><u>General Settings:</u></b><br><br>
            <form action=\"account.php?sid=$sid&p=general&s=update\" method=\"post\">
            <b>Name:</b><br>
            <input type=\"text\" name =\"username1\" value=\"$username\"><br><br>
            <b>Email:</b><br>
            <input type=\"text\" name =\"email1\" value=\"$email\"><br><b>
<u>Note:</u> Make sure you enter a valid email address, otherwise your account will be as good as lost.</b><br><br>
            <b>Password:</b><br>
            <input type=\"checkbox\"><b>Change Password</b><br>
            <table border=\"0\" width=\"300\" bgcolor=\"#ffffff\" cellpadding=\"0\" cellspacing=\"0\">
            <tr>
                <td width=\"150\">
                <u>Current Password:</u>
                </td>
                <td width=\"150\">
                <input type=\"password\">
                </td>
            </tr>
            <tr>
                <td width=\"150\" height=\"20\">
                </td>
                <td width=\"150\" height=\"20\">
                </td>
            </tr>
            <tr>
                <td width=\"150\">
                <u>New Password:</u>
                </td>
                <td width=\"150\">
                <input type=\"password\">
                </td>
            </tr>
            <tr>
                <td width=\"150\">
                <u>Confirm New Password:</u>
                </td>
                <td width=\150\">
                <input type=\"password\"><br><br>
                </td>
            </tr>
            </table><br>
            <center><input type=\"submit\" value=\"Update\"></center><br>
            </form>
            "
;
        }else{
            if (
$username1 !== "$username"){
                
$query mysql_query("SELECT username FROM account WHERE username='$username1'");
                
$num mysql_num_rows($query);
                
$query mysql_query("SELECT username FROM verify WHERE username='$username1'");
                
$nums mysql_num_rows($query);

                if (
$num || $nums 0){
                    echo
"<b>Error!</b> The username is already taken.<br>";
                }
                if (
strlen($username1) <= 3) {
                    echo 
"<b>Error!</b> The username is too short.<br>";
                }
            }elseif (
$email1 !== "$email"){
                
$query mysql_query("SELECT email FROM account WHERE username='$username1'");
                
$num mysql_num_rows($query);
                
$query mysql_query("SELECT email FROM verify WHERE username='$username1'");
                
$nums mysql_num_rows($query);

                if (
$num || $nums 0){
                    echo 
"<b>Error!</b> The email you have submitted is already in use.</b>";
                }
                if (!
ereg("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$"$email1) ){
                    echo 
"<b>Error!</b> The email you have submitted has been detected as being invalid.";
                }
            }else{
                
mysql_query("UPDATE account SET username='$username1', email='$email1' WHERE id='$id'");
                echo
"<center><b>[Updated your settings]</b></center>";
            }
        }
        } 
Thanks,
Nitro is offline   Reply With Quote
Old 11-02-2003, 12:33 PM   #2 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
$email1 !== "$email"

i dont think you should have double ='s here....
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 11-02-2003, 12:57 PM   #3 (permalink)
Nitro
Registered User
 
Nitro's Avatar
 
Join Date: Jun 2003
Location: London, England
Posts: 29
Nitro is on a distinguished road
Send a message via AIM to Nitro
What is the difference between !== and != ?
Nitro is offline   Reply With Quote
Old 11-02-2003, 01:27 PM   #4 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
In looking at the PHP manual page for <comparison operators>, there is a subtle difference between the two.

!= is NOT EQUAL TO
!== is NOT IDENTICAL TO

In the case of your script, either should do what you want, I don't think that's your problem.


Shouldn't this
PHP Code:
if ($p == "general"){ 
be this
PHP Code:
if ($_GET['p'] == "general"){ 
Unless you've got register_globals on, or you define $p further up in your script, then $p hasn't been initialized and won't evaluate properly. I notice you have $_GET['s'] so I have reason to suspect this is your problem. Same thing with all your other values, change $username1 to $_POST['username1'], etc.
bdl is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with editing profile cheawick Feedback 0 04-28-2004 10:26 PM
JavaScript Problem dawkim HTML, XML, Javascript, AJAX 2 01-26-2004 07:02 PM
Help debugging a power problem Belisarius Lounge 0 10-25-2003 04:44 PM
structure problem Goshi Standard C, C++ 5 04-21-2003 12:19 AM
This is a windows/C problem UnderWing Standard C, C++ 6 03-28-2003 06:17 AM


All times are GMT -8. The time now is 10:02 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting