Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,

I'm currently working on a website that you log into, and it needs a changing username part of it.

My update query seems to be ok, but my php is not:

PHP
<?php

$con = mysql_connect("~-~-~-~","~-~-~-~","~-~-~-~");

if (!$con){
    die('Could not connect: ' . mysql_error());
}

mysql_select_db("~-~-~-~", $con);

$username_update = mysql_query("UPDATE users SET username='" . $_GET['confirm_username'] . "' WHERE username='$my_username'");

$username_select = mysql_query("SELECT username FROM users WHERE username = '" . $_GET['confirm_username'] . "'");

$row = mysql_fetch_array($username_select);

if (!$row = $my_username){
    ?>
        <div id="username_changed_green">
            Username Changed
        </div>
    <?php
}else{
    ?>
        <div id="incorrect_details_username">
            Incorrect Details
        </div>
    <?php
}
mysql_close($con);
?>


On the website when it is live, the incorrect details box just shows, any suggestions?

Regards,
Tom.
Posted
Comments
solutions@ashish 21-Mar-12 9:11am    
Where is the form, and where is the form method to post or get myusername value,
Can you please describe the place by where you get confirm username value "$_GET['confirm_username']"

If You write only this code which you have shared with us, then I want to say that this code is uncompleted

Please share complete code

PHP
if (!$row = $my_username){

Are you trying to assign here, or should you be testing for equality? ;o)

Danny
 
Share this answer
 
v2
Change
PHP
if (!$row = $my_username){

to
PHP
if ($row['username'] != $my_username){


Thanks

Anand Ayyappan
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900