Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 06-04-2005, 03:42 PM   #1 (permalink)
Logical Demise
Registered User
 
Join Date: Mar 2005
Posts: 3
Logical Demise is on a distinguished road
My script isn't reading and inserting the value of a cookie correctly...

I'm coding my own message boards and I've hit a snag. I'm trying to code the script that will allow the user to start a new topic. One of the fields in the "topics" table is the name of the author, and the info to be put into that field is the info stored in a cookie known as "character".

Everything else about the script works correctly except for this. The author field is just empty, I get no errors... nothing.

Here are the variables:
PHP Code:
$forum $_GET['id'];
$type $_GET['type'];
$character $_COOKIE['character']; 
Those variables are then put into hidden input fields to be taken to the second part of the script that will only run once the form is filled out. The structure of these input tags are:
PHP Code:
<input type="hidden" name="author" value="<?php print "$character"?>" />
                <input type="hidden" name="type" value="<?php print "$type"?>" />
                <input type="hidden" name="forum" value="<?php print "$forum"?>" />
The second time my script is run, I make variables based on the POST'd input:
PHP Code:
$title $_POST['title'];
$content $_POST['content'];
$type $_POST['type'];
$forum $_POST['forum'];
$author $_POST['author']; 
And lastly, this is the query I'm trying to run:
PHP Code:
$query "INSERT INTO topics (id,title,forum,author,replies,lastpost,icon,created,content) VALUES (0,'$title','$forum','$author',0,NOW(),'$type',NOW(),'$content')"
As I said before, everything BUT the author field is being filled as it is supposed to. I have also noticed that if I reduce the URL from "new.php?id=1&type=ooc" to simply "new.php" I can PRINT out the cookie's variable, so something is being stored there. However, the script isn't running correctly that method either.

Thanks in advance!
Logical Demise is offline   Reply With Quote
Old 06-05-2005, 12:42 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Have you tried accessing it through $HTTP_COOKIE_VARS ? or perhaps $_REQUEST or at some points $_SESSION would be useful.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 10:45 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting