Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Need help on mysql query

Codes here !

Moderators: macek, egami, gesf

Need help on mysql query

Postby apkhan2 » Sat May 18, 2013 1:00 am

Hi, i'm new in php

In user setting.php has 3 input (email, phone and password)

The problem is i can't change single field.

If i need to change single field setting then i have to change all field

Now what to do? here is code

Code: Select all
<?php
session_start();
if (isset($_SESSION['login']) && ($_SESSION['login'] == true)) {
$username = $_SESSION['username'];
if (isset($_POST['change'])){
$email = $_POST['email'];
$phone = $_POST['phone'];
$password = $_POST['password'];
require_once('db.php');
$query = "UPDATE user SET password=md5($password), email='$email', phone='$phone'
WHERE username='$username'";
mysql_query($query) or die('Unable to save settings');
echo "Settings changed to $password - - $email - - $phone";
}
else{
print("
<form method=\"POST\" action=\"\" >
<br/>

Change email
<br/><br/>

<input type=\"text\" name=\"email\" />
<br/>
<br/>
Change Phone number
<br/><br/>

<input type=\"text\" name=\"phone\" />
<br/>
<br/>

<br/>
Change password
<br/><br/>

<input type=\"text\" name=\"password\" />
<br/>
<br/>

<input type=\"submit\" value=\"Change settings\" name=\"change\" />

</form>
<br/>
");
}
}
else{echo "You are not login";}
?>
apkhan2
New php-forum User
New php-forum User
 
Posts: 4
Joined: Fri May 17, 2013 11:57 pm

Re: Need help on mysql query

Postby pbs » Sun May 19, 2013 10:34 pm

First of all assign database column values to respective input box values, so whenever you update any single value it will update only that value and the remaining values will be updated as it is
pbs
New php-forum User
New php-forum User
 
Posts: 39
Joined: Sat May 11, 2013 1:40 am
Location: Nashik, India

Re: Need help on mysql query

Postby apkhan2 » Fri May 24, 2013 8:17 am

pbs wrote:First of all assign database column values to respective input box values, so whenever you update any single value it will update only that value and the remaining values will be updated as it is

Thanks It's worked.
apkhan2
New php-forum User
New php-forum User
 
Posts: 4
Joined: Fri May 17, 2013 11:57 pm


Return to mySQL & php coding

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.