Ok i am a little bit confused, please remember i am a total novice. So i found an example online of how to insert a value into a table, it consists of 2 files “insert.php” & “insert_ac.php” … it seems to function to an extent in that it inserts a new row into the correct table, although there is no visible content in the row. My problem is that i need it to insert the value into a specific column beside the currently logged in member. so my “members” table has columns id, username, password, email, listname of which the first four are created by the registration script. My insert_ac.php is supposed to then enter a list name into “listname” but it’s actually just creating a new row on the table with a new id … please help … below is some code which may be useful.
insert.php
[code]
Create Song List |
Song List |
: |
|
|
|
[/code]
insert_ac.php
[php]<?php
$host=“localhost”; // Host name
$username=“"; // Mysql username
$password="”; // Mysql password
$db_name=“giftgang_cdg”; // Database name
$tbl_name=“members”; // 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”);
// Get values from form
$name=$_POST[‘listname’];
// Insert data into mysql
$sql=“INSERT INTO $tbl_name(listname)VALUES(’$listname’)”;
$result=mysql_query($sql);
// if successfully insert data into database, displays message “Successful”.
if($result){
echo “”;
}
else {
echo “ERROR”;
}
?>
<?php
// close connection
mysql_close();
?>[/php]
And this is the current code for all members pages, which may be off use for determining the current username
[php]<? ob_start(); session_start();include_once"config.php";
if(!isset($_SESSION[‘username’]) || !isset($_SESSION[‘password’])){
header(“Location: login.php”);
}else{
$user_data = “”.$_SESSION[‘username’]."";
$fetch_users_data = mysql_fetch_object(mysql_query(“SELECT * FROM members
WHERE username
=’”.$user_data."’"));
}
?>[/php]
Please accept my apologies if i am on the wrong track and have provided duff information. Thanks again for any help.