rawkhopper Posted August 13, 2012 Share Posted August 13, 2012 Hi guys, I am very new to php and when I started this project I thought I was keeping it simple to just reduce cutting and pasting to a bunch of different pages updates. Anyway I settled on php with a main page with switch and case to get the job done. The page works beautifully with one known exception. One of my pages calls a php page (that I did not write) and uses a ? appended to the URL to pass arguments? to the php page. If I set the default case to the php page that the arguments need to pass through to then all works well. But if I set the default to any other page the argument is sent to the default page. Is there a way to pass the argument to the appropriate page? I have tried to search for the answer but due to my lack of knowledge I am unsure how to search for the answer. So to rephrase I have a simple php page that uses switch and case to call other php pages that are really just html. One of the pages called through a case is a true php page that I did not write. Arguments, or whatever you call them, are passed through to the php page through a ? in the address bar. Unfortunately I can only pass arguments in the address bar to the default case. Can anyone help me send these arguments to a non default page? Quote Link to comment https://forums.phpfreaks.com/topic/267023-php-switch-case-and-passing-info-from-one-page-to-another/ Share on other sites More sharing options...
Christian F. Posted August 13, 2012 Share Posted August 13, 2012 Can you please show us some code, along with a couple of examples showing the problem and how you'd like it to work? PS: Please use the tags around your code when posting it, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/267023-php-switch-case-and-passing-info-from-one-page-to-another/#findComment-1369156 Share on other sites More sharing options...
scootstah Posted August 13, 2012 Share Posted August 13, 2012 If your switch is just including pages then it shouldn't be a problem, since the included page can access the $_GET global. Quote Link to comment https://forums.phpfreaks.com/topic/267023-php-switch-case-and-passing-info-from-one-page-to-another/#findComment-1369157 Share on other sites More sharing options...
rawkhopper Posted August 13, 2012 Author Share Posted August 13, 2012 Arrg asked the question but now I feel so stupid. I did not look to see how the php script that is not mine is sending arguments to itself. Anyway I figured out what is going on and a slight mod to the script that I did not write will work. Sorry I can't really post examples as that would take too much work since I would have to know more about the php that I didn't write. My guess is that posting a link to a site is probably frowned upon. But thanks for the willingness to help out a newb. Quote Link to comment https://forums.phpfreaks.com/topic/267023-php-switch-case-and-passing-info-from-one-page-to-another/#findComment-1369166 Share on other sites More sharing options...
scootstah Posted August 13, 2012 Share Posted August 13, 2012 You could put the whole script on pastebin, or upload it as an attachment. Quote Link to comment https://forums.phpfreaks.com/topic/267023-php-switch-case-and-passing-info-from-one-page-to-another/#findComment-1369167 Share on other sites More sharing options...
rawkhopper Posted August 13, 2012 Author Share Posted August 13, 2012 Well your comment If your switch is just including pages then it shouldn't be a problem, since the included page can access the $_GET global. helped me to think about how the other php script (that I didn't write) sent arguments to itself. It simply tacks on the end of the address its arguments. I needed to tack my argument into that script. simple example hope it helps $titleLink = sprintf("<a href='?Sermon=%d'>%s</a>", $row['Id'], htmlspecialchars($row['Title'])); the script I did not write used this to create a page for a specific audio file. Unfortunately that will simply pass through to the default page on my php. so I changed my script to include a dummy page that shows every audio file in the database. case "everything": $sermonsWebPart = GetSermonsWebPart(array('DefaultSinceWeeks' => All)); @include ('sermonsbanner.php'); @include ('sermons.php'); break; then I modified the line in the script i did not write to $titleLink = sprintf("<a href='?cmd=everything&Sermon=%d'>%s</a>", $row['Id'], htmlspecialchars($row['Title'])); This then passes the argument through to the appropriate script. And now I have a working script. Thanks for that little tip. Sometimes it just takes a couple words to make me rethink things. Thanks a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/267023-php-switch-case-and-passing-info-from-one-page-to-another/#findComment-1369173 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.