PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 9th, 2012, 02:28 PM
johnadamos johnadamos is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 16 johnadamos User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 13 m 6 sec
Reputation 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
         <
titleLogin 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> 

Reply With Quote
  #2  
Old December 9th, 2012, 02:38 PM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,867 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 1 Week 5 Days 9 h 6 m 6 sec
Reputation Power: 581
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!
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Last edited by gw1500se : December 11th, 2012 at 03:36 AM.

Reply With Quote
  #3  
Old December 9th, 2012, 03:17 PM
johnadamos johnadamos is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 16 johnadamos User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 13 m 6 sec
Reputation Power: 0
Got it!! thx1

Reply With Quote
  #4  
Old December 11th, 2012, 12:07 AM
jaysh4922 jaysh4922 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 31 jaysh4922 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 5 m 22 sec
Reputation Power: 1
you cant use commas with the update function. you must use the keyword AND.

example like

$sql = "UPDATE table SET row1 = 'value' AND SET row2 = 'value' WHERE row3 = 'value'";
$result = mysql_query($sql);

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP MYSQL update

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap