#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0

    PHP MYSQL update


    Hello, how I could use this code
    PHP Code:
    $user_data login_user$_POST['username'] , $_POST['password'] );
            
    $result mysql_query("UPDATE users SET username = '$user WHERE password = '$password'" or die(mysql_error()); 
    in my php code , so the user will be able to udpate his data from a form.
    PHP Code:
    <html>
    <head>
    <body>
    <html> 
            <head> 
             <title> Login Page </title> 
                
                <style type="text/css"> 
                            body { 
                                    background-color:#3b5999; 
                                    color:#999; 
                                    font-family:Arial; 
                                    font-size:9pt; 
                            } 
                            #holder { 
                                    width:80%; 
                            background-color:#CCC; 
                                    color:#F00; 
                                    font-family:Arial; 
                                    border:1px solid #003; 
                                    padding:12px; 
                                    text-align:right; 
                            } 
                            
                            #userInfo { 
                                          
                                            color:#000; 
                                            font-family:Arial; 
                                            border:1px solid #CCC; 
                                            text-aling:right; 
                                            padding:2px; 
                            } 
                </style> 
          </head> 
          <body> 
             <center> 

    <?php
        
        
    // Replace the variable values 
      
    $host "127.0.0.1";
      
    $root "root";
      
    $pass "";
      
    $database "test";
      
     
    //Connects to Mysql or displays  error
    $con mysql_connect($host,$root,$pass) or die(mysql_error());
     
    //"my_db" is the name of the database.
    $db mysql_select_db($database ,$con);    




        
    ?>

        
    <div id="container">

            <h1>Login</h1>
        
        
        <p>
            <form method="post" action="" id="form">
                <label>Username:</label> <input type="username" name="username" value="" /><br />
                <label>Password:</label> <input type="password" name="password" value="" /><br /><br />
                <input type="submit" value="Submit" />
                
                <?php echo $error
                     
                
    ?>   
                
              </form></table>
         </body>
         </html>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,616
    Rep Power
    595
    You don't. For one thing the MySQL extensions are deprecated. You should be using PDO.

    As to where to put it. It can go anywhere but you need to wrap it in an 'if (isset($_POST['Submit'])) {}' block.

    Comments on this post

    • johnadamos agrees
    Last edited by gw1500se; December 11th, 2012 at 04:36 AM.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0
    Got it!! thx1

IMN logo majestic logo threadwatch logo seochat tools logo