i am working on a project
in which i need to create a option for for editing a user’s profile…
but getting error now …
update.php (script for present the saved data) :
<?php include('lock.php'); $host="localhost"; // Host name $username="root"; // Mysql username $password="*****"; // Mysql password $db_name="dailynotes"; // Database name $tbl_name="userinformation2"; // Table name $user=$login_session; // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // get value of id that sent from address bar $id=$_GET['id']; // Retrieve data from database $sql="SELECT id,firstname,lastname,username,emailid,password FROM $tbl_name where id='$id' "; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?>
|
second file which performs the update in mysql database
update_ac.php :
<?php include('lock.php'); $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $username=$_POST['username']; $email=$_POST['emailid']; $password=$_POST['password']; $id=$_GET['id']; $connection=mysql_connect("localhost","root","****") or die("unable to connect with database"); $db=mysql_select_db("dailynotes",$connection) or die("unable to find such database"); if(isset($_REQUEST['submit'])) { $query="UPDATE userinformation2 SET firstname='$firstname',lastname='$lastname',username='$username',emailid='$email',password='$password' where id='$id' "; $result=mysql_query($query) or die("query failed:".mysql_error()); if($result) { echo"success"; } } ?>check the code …
help plz…