Mourning the loss of our friend, WhitPhil.
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 audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel firefox hard drive hardware internet keyboard laptop malware monitor motherboard network networking outlook problem processor ram recovery router safe mode screen slow sound spyware tdlwsp.dll trojan upgrade video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
php sending wrong information

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
twmprys's Avatar
Computer Specs
Member with 69 posts.
 
Join Date: Jun 2009
Experience: Beginner
08-Nov-2009, 06: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, 08: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 69 posts.
 
Join Date: Jun 2009
Experience: Beginner
08-Nov-2009, 08: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
Distinguished Member with 3,519 posts.
 
Join Date: Oct 2006
08-Nov-2009, 11:32 PM #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 69 posts.
 
Join Date: Jun 2009
Experience: Beginner
09-Nov-2009, 04: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 Bookmark and Share

Smart Search

Find your solution!



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


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 05:49 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.