PDA

View Full Version : not getting any data from form.


thesavior
01-09-2006, 01:52 AM
My code is:

<?php
if( !isset($_SESSION['login_username'])){
header("Location: index.php?act=admin");
} else {

if(isset($_GET['action']) AND $_GET['action'] == "edittutsnow"){
if ($_POST['approve'] == 1) {
// SQL to update row to be active
} else if ($_POST['approve'] == 2) {
// SQL to delete row
} else if ($_POST['approve'] == 3) {
// SQL to update row
$update = "UPDATE $tuttable SET image = '".$_POST['image']."', title = '".$_POST['title']."', tuturl = '".$_POST['tuturl']."', category = '".$_POST['category']."', author = '".$_POST['author']."', descr = '".$_POST['descr']."' WHERE id = '".$_POST['id']."'";
mysql_query($update)or die(mysql_error());
echo $update;
}
}

mysql_connect ($dbhost, $dbusername, $dbuserpass)or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$query = "SELECT * FROM $tuttable WHERE onoff='0' ORDER BY id DESC";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
echo
"<table style=\"clear: both;\">
<form action=\"index.php?act=adminlog&do=edit&action=edittutsnow\" method=\"POST\">
<tr>
<td rowspan=\"2\">
<img width=\"40\" height=\"40\" alt=\"preview\" src=\"".$row['image']."\" />
</td>
<td align=\"center\">
Title: <input type=\"text\" name=\"name\" value=\"".$row['title']."\" />
</td>
<td align=\"center\">
Author: <input type=\"text\" name=\"authorname\" value=\"".$row['author']."\" />
</td>
<td align=\"center\">
Tut-URL: <input type=\"text\" name=\"loca\" value=\"".$row['tuturl']."\" />
</td>
<td align=\"center\" rowspan=\"2\" colspan=\"2\">
<select name=\"approve\" id=\"approve\">
<option value=\"3\" selected=\"selected\">Edit</option>
<option value=\"1\">Approve</option>
<option value=\"0\">Leave as is</option>
<option value=\"2\">Delete</option>
</select>
<br />
<input type=\"hidden\" name=\"idnum\" value=\"".$row['id']."\" />
<input type=\"submit\" class=\"submit\" value=\"Go\" />
<br />
<input type=\"reset\" class=\"submit\" value=\"Reset\" />
</td>
</tr>
<tr>
<td colspan=\"1\">
<textarea name=\"descrip\">".$row['descr']."</textarea>
</td>
<td align=\"center\">
<input type=\"radio\" name=\"cat\" value=\"Photoshop\" checked/> Photoshop<br />
<input type=\"radio\" name=\"cat\" value=\"PHP\" /> PHP<br />
<input type=\"radio\" name=\"cat\" value=\"PSP\" /> PSP<br />
<input type=\"radio\" name=\"cat\" value=\"PSE\" /> PSE<br />
</td>
</tr>
<tr>
<td colspan=\"7\">
Preview Location:
<input type=\"text\" value=\"".$row['image']."\" name=\"preview\" size=\"55\" />
</td>
</tr>
</form>
</table>";
}
}
?>

and im echoing the update query, and it is returning: UPDATE tut_tutorials SET image = '', title = '', tuturl = '', category = '', author = '', descr = '' WHERE id = ''

Which means that for some reason it isn't getting data from the form. What do i change in my code to make it work?

vinyl-junkie
01-09-2006, 03:05 AM
You are using method=post in your form, but I notice in a couple of places that you're referencing $_GET['action']. Those need to be changed to $_POST['action'] instead. Perhaps that will fix your problem.

thesavior
01-09-2006, 03:39 AM
no, it needs to be get, because it is getting the information from the url, which means it has to be get.

vinyl-junkie
01-09-2006, 03:46 AM
So change your form to method=get, and change all your $_POST variables to $_GET variables.

thesavior
01-09-2006, 05:58 AM
Changing everything to get doesn't work either.

vinyl-junkie
01-09-2006, 12:32 PM
Did you change your form to method=get? You need that, too. Do you still have your echo statements in your script? If not, put them back in. Also, put a few at the very top of the script to see what the value of your variables are coming into it each time. That will tell you a whole lot about what's going on.

thesavior
01-09-2006, 02:57 PM
the variables are empty, i know that, but how do i make them...not empty...?

and yes, i did changet the form method to get. Nothing happens though.

vinyl-junkie
01-10-2006, 01:33 AM
I think I may know what the problem is. Post the source code for your rendered page, just the stuff between the <form></form> tags.