Page 2 of 2

Posted: Fri Aug 16, 2002 5:09 am
by twigletmac
There doesn't seem to be any data being posted - what does the form that sends the data look like?

Mac

Posted: Fri Aug 16, 2002 5:21 am
by dreamtime
what I dont understand is that some of the code works fine and some doesnt

Posted: Fri Aug 16, 2002 5:27 am
by dreamtime
the code has come from this page if you scroll down there is a 3 part tutorial for a news system I havent changed anything that I shouldnt of.
http://www.oxyscripts.com/tutorial_cat.php?cat=php

Posted: Fri Aug 16, 2002 5:28 am
by dreamtime

Code: Select all

<form name="post news" method="post" action="post_news_process.php">
  <p>Title :
  <input type="text" name="title"><br>
  Author : 
    <input type="text" name="author">
    <br>
    News :<br>
    <textarea name="news" cols="40" rows="6"></textarea>
  </p>
  <p>
    <input type="submit" name="Submit" value="POST !">
  </p>
  </form>
this is the form

Posted: Fri Aug 16, 2002 5:30 am
by volka
hmmm...if there is a <form> is the method-property set to "POST" or "GET" or isn't set at all?

POST: oops, you have a serious problem with your server ;)
GET: try

Code: Select all

$query = "DELETE FROM news WHERE id = ".$_GET&#1111;'id'];
edit: ahem, where does the id come from? It's not within the form, is it?

Posted: Fri Aug 16, 2002 5:35 am
by dreamtime
sorry vodka that didnt work either... could the problem be that it is running on an nt server?

Posted: Fri Aug 16, 2002 5:38 am
by volka
don't think so.
I took a (very) brief overview on the tutorial.
EDIT: and I took a second look ;)
/* Now lets display the titles */

echo "<A HREF=\"edit_process.php?id=$id\">$title</A><BR>";
}
[...]using your knowledge that you have gleened from these 3 tutorials, and using the query DELETE FROM news WHERE id = $id
ok, so you added something like

Code: Select all

echo "<A HREF="edit_delete.php?id=$id">$title</A><BR>";
?
Then with php version <= 4.1.0 $id should contain the id.
From 4.2.x it should be in $_GET['id']

Posted: Fri Aug 16, 2002 5:45 am
by dreamtime
you are right that is what I have done and yes I do have a delete_save.php

Posted: Fri Aug 16, 2002 5:48 am
by volka
when pointing the mouse over that link does the status bar of the browser show you the right url?
i.e. http://localhost/delete_save.php?id=23

Posted: Fri Aug 16, 2002 5:50 am
by dreamtime
half the problem is that the view.php doesnt work correctly and all I have done is use the tutorial code. Is it the code from the tutorial that is incorrect or me??

Posted: Fri Aug 16, 2002 5:56 am
by volka
the tutorial assumes that you can access data from href="script.php?id=12" simply by $id
But now you have to use $_GET['id'] by default.

this change of behaviour is the topic of this thread

Posted: Fri Aug 16, 2002 6:00 am
by dreamtime
It was set to off but now I have had them turned on

Posted: Fri Aug 16, 2002 6:02 am
by dreamtime
if you look at the tutorial again you will see an edit.php and edit_process.php and edit_save.php these all work fine. The one that dont are the view.php and my new delete.php ones I have just done as instructed and made a page to delete the information.

Posted: Fri Aug 16, 2002 6:26 am
by volka
hmmm...I did. And yes, it is a bit -well- sloppy.
I suggest you look for another tutorial ;)