ComputerForum.com ComputerForum.com  
TigerDirect
 
Go Back   Computer Forum > General Chat > General Computer Chat

Reply
 
LinkBack Thread Tools Display Modes
Old 07-13-2006, 04:13 AM   #1 (permalink)
Silver Member
 
Flipper's Avatar
 
Join Date: Apr 2006
Location: USA
Posts: 121
Default PHP Script, help needed!

I am working on a PHP Script and my insert query seems to be on the fritz, when the link is at newthread.php?fid=1 (fid means forum id which distinguishes what forum it is being posted in)

$fid = $_GET['fid']; is set for the insert query, using the above link would insert the fid as 1, but for some odd reason inserts it as 0 everytime. I have tried everything, can anyone help?

My code is located here:
http://paste.ubuntu-nl.org/17878
__________________
dotOmega Forum System - It's whats for cool people.
Too bad it's still in development :).

98% of the teenage population will try, does or has tried smoking pot. If you're one of the 2% who hasn't, copy & paste this into your signature
Flipper is offline   Reply With Quote


Old 07-13-2006, 07:02 AM   #2 (permalink)
Bronze Member
 
Join Date: Jun 2006
Location: Blacksburg, VA
Posts: 96
Default

Im not the best at php...but I've always found the site phpfreaks.com helpful...their forum may be able to help a little more.
nick5449 is offline   Reply With Quote
Old 07-14-2006, 02:15 AM   #3 (permalink)
VIP Member
 
Chroder's Avatar
 
Join Date: Dec 2003
Location: Toronto, Ontario
Age: 19
Posts: 1,302
Default

The initial request would have $_GET['fid'] as 1. But after they submit the form (and thus the code ot insert into the database is run), the $_GET variables are not kept across another page load.

The best way is to insert a hidden form field with the variable, and then use $_POST as the fid:

Code:
...
<form action="newthread.php" method="POST">
 <input type="hidden" name="fid" value="<?php echo $_GET['fid']; ?>" />
PHP Code:
 $fid = $_POST['fid'];
Also note that unless you are running with magic_quotes enabled, you are vulnerable to SQL injection. You should 1) Disable magic_quotes (it's unreliable across different installs) so you can take care of slashes on your own. Then always run mysql_real_escape_string() on variables you use in your queries.
__________________
:: Devlog - New developer blog with useful PHP information
::
The New Tech - Technology Forum
:: WeTalk.tv - TV Forums

Last edited by Chroder; 07-14-2006 at 02:19 AM.
Chroder is offline   Reply With Quote
Reply

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 +1. The time now is 05:12 PM.


Powered by: vBulletin Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Copyright © 2002-2007 Computer Forum and Web Design Forum