|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with PHP form submission...
Greets,
I seem to have a small problem with a form and how it submits. I have a delete script and the form. Now it Echos a success message but doesnt delete anything, so let me copy and paste the code: For the Form: <HTML> <Body> <form action="/corporate/testdelete.php"> <?php $dbh=mysql_pconnect ("localhost", "cliekid", "clienr70v") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("cliekid_admin"); $result = mysql_query("SELECT * FROM news"); $select = "<SELECT name=\"test\">"; $submit = "<BR><input type=\"submit\" value=\"Delete News\">"; $text = "<BR><BR>Insert Article Date: <input type=\"text\" name=\"test2\">"; $i = "0"; while ( $row = mysql_fetch_array($result) ) { // if first itteration if ( $i == '0' ) { $option = "<option value=\"".$row['news_name']."\" />".$row['news_name']." - ".$row['news_date']." - By: ".$row[news_writer]; } else { echo ("There is nothing to delete!"); } } $option.="</SELECT>"; echo $select,$option,$text,$submit; ?> </form> </Body> </HTML> For the Delete Script: <?php $dbh=mysql_pconnect ("localhost", "cliekid", "clienr70v") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("cliekid_admin"); $sql ="DELETE FROM news WHERE news_name = '$_POST[test]' AND news_date = '$_POST[test2]'"; $result = mysql_query($sql); if (!$result) { die('Invalid SQL!: ' . mysql_error()); } else { echo ("News Article Succesfully Deleted!"); } ?> Any ideas? I need it so when the selected fields, date and name, are selected the article deletes via removing its row, but, it doesnt. Help! Thanks, -Cliekid |
|
#2
|
||||
|
||||
|
Take a look at your query. Echo it and see what it returns. I guess that there's a problem with the $_POST variables.
Try this one: PHP Code:
And BTW, could you post in the appropiate forum next time and put your code between the assigned BB-tags? Cheers,
__________________
Work to live, don't live to work |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Help with PHP form submission... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|