Results 1 to 10 of 14
Threaded View
-
16th Apr 2011, 08:21 PM #12MemberWebsite's:
epicimagehost.comI think you only need to update the 'update_ac.php' file:
PHP Code:<?php
//I assume this is update_ac.php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="test_mysql"; // Table name
// 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");
// update data in mysql database
$sql='UPDATE '.$tbl_name.' SET username="'.mysql_real_escape_string($_POST['username']).'", password="'.mysql_real_escape_string($_POST['password']).'", email="'.mysql_real_escape_string($_POST['password']).'" WHERE id='.intval($_POST['id']);
/*
this query might work aswell ( note the different type of quotes used ) but use the one above
$sql="UPDATE $tbl_name SET username='mysql_real_escape_string($_POST['username'])', password='mysql_real_escape_string($_POST['password'])', email='mysql_real_escape_string($_POST['password'])' WHERE id=intval($_POST['id'])";
*/
/*
In php these are thesame:
$cool = "awesome";
echo "lol this is $cool"; <- this shows : lol this is awesome
echo 'lol this is '. $cool; <- this shows : lol this is awesome
*/
/*
the dot ( . ) acts as glue.
For example:
$this = 'Hi';
$still = ', how';
$works = ' are you';
echo $this . $still . $works . 'doing?'; <- This shows : Hi, how are you doing?
so does this btw:
echo $this.$still.$works.'doing?'; ( the space doesn't matter )
*/
/*
Now about the $_POST[''] variable I used in your query ( line 14 )
Whenever you submit a form [ remember the <form method="post".. u used in your HTML ? ] to a script, the data you send
gets stored in the $_POST array.
For example:
<input type="text" name="KWWHunction" /> ( let's assume you entered sucks and pressed submit )
it will be handled in the script with:
$_POST['KWWHunction']
So if you do this in your script:
echo $_POST['KWWHunction'];
That will show the word sucks
*/
$result=mysql_query($sql);
// if successfully updated.
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='list_records.php'>View result</a>";
}
else {
echo "ERROR";
}
?>
Added a bit of info as it seems you are quite new with this.
Not sure if what I said is correct, i'm really tired atm
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
themaCreator - create posts from...
Version 3.53 released. Open older version (or...