a few n00b questions

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

Post Reply
Mendes
Forum Newbie
Posts: 3
Joined: Fri Mar 26, 2004 10:31 am

a few n00b questions

Post by Mendes »

first things first..

1. to redirect someone to a different page say if and if statement is true what is the best method?

header("Location: page.php");

the above is what i found in one of the tutorials is that the best way?

2. if i want to have a kill script that erases all information in my database what is the best way?

$del = "DELETE * FROM database"
$kill=mysql_query($del);

?

is that the best way.

3. are cookies the best/only way to automatically log somone in when they return to my site?

Thanks in advance!
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

1. yes, but have a look at HTML Metatags. Forwarding in javascript can also be handy. It does depend on the situation/application
2. to delete a table write "DROP TABLE tablename"
3. They are a convenient and, on the internet, the only way (to my knoweldge). If there are other ways, I'd love to hear about them. :)

moved to PHP - Code, btw.
Mendes
Forum Newbie
Posts: 3
Joined: Fri Mar 26, 2004 10:31 am

Post by Mendes »

patrikG wrote:1. yes, but have a look at HTML Metatags. Forwarding in javascript can also be handy. It does depend on the situation/application
2. to delete a table write "DROP TABLE tablename"
3. They are a convenient and, on the internet, the only way (to my knoweldge). If there are other ways, I'd love to hear about them. :)

moved to PHP - Code, btw.
Thanks. I do not want to delete the table just the information stored in it.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

use "TRUNCATE tablename"
Mendes
Forum Newbie
Posts: 3
Joined: Fri Mar 26, 2004 10:31 am

Post by Mendes »

patrikG wrote:use "TRUNCATE tablename"
and that will totally clear out everything and leave me with an empty table? no fields period right?

Thanks a lot!
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Yup. :)
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

TRUNCATE will also set an auto_increment column to zero, if anyone cared. lol

8)
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Mendes wrote:no fields period right?
patrikG wrote:yup
by fields do you mean the column names,right? So it just leaves a blank table in the database? So it would be the same as deleting the whole table and making a new one with the same name?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Yeah.
http://www.mysql.com/doc/en/TRUNCATE.html pretty much covers the ins and outs of it.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

ahh! ok, thanks!!
Post Reply