Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Web Design & Development
Tag Cloud
access acer asus bios bsod computer crash driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop mac malware memory monitor motherboard music network printer problem ram registry router server slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
php sending wrong information

Reply  
Thread Tools
twmprys's Avatar
Computer Specs
Member with 106 posts.
 
Join Date: Jun 2009
Experience: Beginner
08-Nov-2009, 07:56 PM #1
php sending wrong information
I wonder if some nice person could spot what I'm doing wrong here? This script lists the newsletter issues in a directory and allows you to press on a link which should post that specific issue number to the next page. Trouble is, the same number is posted whichever link is pressed.

PHP Code:
$dir opendir('newsletters/');

while (
false !== ($read readdir($dir))) {
if (
substr($read,0,5)=='Issue') {
$issue=substr($read,5,2);
echo 
'<form name="form' $issue '" method="POST" action="newpage.php">';
echo 
'<input name="issue" type="hidden" value="' $issue '" /><a href="javascript: submitform()">Issue ' $issue '</a></form>
<SCRIPT language="JavaScript">
function submitform()
{
  document.form' 
$issue '.submit();
}
</SCRIPT>'
;
}
}
closedir($dir); 
midders's Avatar
Account Closed with 654 posts.
 
Join Date: Dec 1969
08-Nov-2009, 09:25 PM #2
Examine the HTML page source that is generated by your script to find the problem, or post it here.
twmprys's Avatar
Computer Specs
Member with 106 posts.
 
Join Date: Jun 2009
Experience: Beginner
08-Nov-2009, 09:38 PM #3
Thanks so much for replying. The page posts to another page (calling it "newpage.php" in the script is a bit confusing - it's just another page). WIthout boring you with all the script, basically I'm trying to catch the incoming post with:

PHP Code:
$issue $_POST['issue']; 
then I use it in the rest of the script, such as

PHP Code:
$query "SELECT * FROM newslettertable WHERE issue='" $issue "' ORDER BY id"
etc.
MMJ's Avatar
MMJ MMJ is offline
Senior Member with 3,637 posts.
 
Join Date: Oct 2006
09-Nov-2009, 12:32 AM #4
You're creating a lot of javascript functions with the same name: submitform. That's your problem.

Also, you're over-complicating things so badly it's amazing.

PHP Code:
$dir opendir('newsletters/');

while (
false !== ($read readdir($dir))) {
    if (
strtolower(substr($read05)) == 'issue') { //case insensitive check
        
$issue substr($read52);
        echo 
'<a href="newpage.php?issue=' $issue '">Issue ' $issue '</a><br>';
    }
}
closedir($dir); 
Use that and on newpage.php replace $_POST['issue'] with $_GET['issue']
twmprys's Avatar
Computer Specs
Member with 106 posts.
 
Join Date: Jun 2009
Experience: Beginner
09-Nov-2009, 05:50 AM #5
Well, yes - I'd convinced myself I had to POST the information and wanted a text link instead of a SUBMIT button. GET is better, you're right. I want to list all items in the directory beginning with the word Issue (cap I) - but I'm now not seeing anything in the list at all....
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 05:11 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.