Hi all!! Brand new to this place and so far the forum is best by far!!

Now to the good stuff:
I am currently working on a project that involves php and mysql. The part that I am now is the "admin" section. I am setting up so the user can add/delete/edit things to the database. Now I have the add part down its the next two that I have had some trouble with. Everywhere I search for has information on how to do everything to your database, behind the scenes, not on the user end. So here is the code that is for the "edit" page:

<?php 

$dbh=mysql_connect ("localhost", "blah", "blah") or die ('I cannot connect to the database because: ' . mysql_error()); 
mysql_select_db ("snmwebde_rynodb");  
if(isset($_GET['search'])) 
$search = $_GET['search']; 
$query ="SELECT * FROM `spots`"; 
$result = mysql_query($query); 

?> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<title>Database View</title> 
</head> 

<body> 
<?php 
while ($row=mysql_fetch_array($result, MYSQL_ASSOC)){ 
foreach($row as $key=>$value){ 
print "<b>$key:</b> 
<table height= '5'> <tr><form name='form1' method='post' action='process.php'> 
  <input type='text' name='textfield' value='$value'> &nbsp;"; 
} 
print "<input type='submit' name='Submit' value='Submit'></tr></form></table><br> 
<br/>"; 
} 

?> 
<p> 
   
</p> 
</body> 
</html>

Now basically what is happening here is that it is displaying all the records in editable form fields with a submit button after each complete record...simple right. Now is where I am stuck. When the user hit submit it goes to a page called "process.php" here is that page:

<? 
$dbh=mysql_connect ("localhost", "blah", "blah") or die ('I cannot connect to the database because: ' . mysql_error()); 
mysql_select_db ("snmwebde_rynodb");  
$category=$_POST{'category'}; 
$client=$_POST{'client'}; 
$keywords=$_POST{'keywords'}; 
$spot_name=$_POST{'spot_name'}; 
$thumbnail_name=$_POST{'thumbnail_name'}; 
$creation_date=$_POST{'creation_date'}; 
$series=$_POST{'series'}; 
$query = "insert into spots values 
('$category','$client','$keywords','$spot_name','$thumbnail_name','$creation_date','$series')"; 
$result = mysql_query($query); 


?> 
Entry added!!<br> 
To view database click <a href="viewdb.php">here</a>.

Now I know I am wrong on this page for a few reasons. Its asking for all of those variables but I am not pulling any of those from the page before....also this is attempting to add a new record, not updating one that is already made. Any and all help will be greatly appreciated. Also on the "delete" part, any ideas would be great. Thanks guys

Are your $_POST statemnts bracketed or braced? The snippet shows them braced, but I realize that could be for the forum eating the brackets...

The proper syntax is to use brackets after $_POST, such as $_POST['myvalue'] .

Lookss like you need to rewrite the process.php page to handle your page's form. You may run in to problems with the foreach loop not giving your output unique names, so watch for that.

Read, consult, and bookmark this page when doing HTML forms:
http://www.w3.org/TR/REC-html40/interact/forms.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.