newbie needs help with code yet again

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

There doesn't seem to be any data being posted - what does the form that sends the data look like?

Mac
dreamtime
Forum Newbie
Posts: 24
Joined: Thu Aug 15, 2002 5:31 am

Post by dreamtime »

what I dont understand is that some of the code works fine and some doesnt
dreamtime
Forum Newbie
Posts: 24
Joined: Thu Aug 15, 2002 5:31 am

Post 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
dreamtime
Forum Newbie
Posts: 24
Joined: Thu Aug 15, 2002 5:31 am

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
dreamtime
Forum Newbie
Posts: 24
Joined: Thu Aug 15, 2002 5:31 am

Post by dreamtime »

sorry vodka that didnt work either... could the problem be that it is running on an nt server?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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']
Last edited by volka on Fri Aug 16, 2002 5:46 am, edited 1 time in total.
dreamtime
Forum Newbie
Posts: 24
Joined: Thu Aug 15, 2002 5:31 am

Post by dreamtime »

you are right that is what I have done and yes I do have a delete_save.php
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
dreamtime
Forum Newbie
Posts: 24
Joined: Thu Aug 15, 2002 5:31 am

Post 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??
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
dreamtime
Forum Newbie
Posts: 24
Joined: Thu Aug 15, 2002 5:31 am

Post by dreamtime »

It was set to off but now I have had them turned on
dreamtime
Forum Newbie
Posts: 24
Joined: Thu Aug 15, 2002 5:31 am

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

hmmm...I did. And yes, it is a bit -well- sloppy.
I suggest you look for another tutorial ;)
Post Reply