Simplicity Posted November 29, 2006 Share Posted November 29, 2006 Hi guys, to start with, thanks for your help previously.I have a form with a drop down list of team names which looks like:[code] <form action="$pageselect" method="post" name="TeamName" id="TeamName"> Select Team Name <select name="TeamName"> <option>Team1</option> <option>Team2</option> <option>Team3</option> <option>Team4</option> <option>Team5</option> <option>Team6</option> </select> <input type="submit" name="Submit" value="Submit">[/code]When submitted I want to post the team name to a variable at the top of the page defined here:[code]<?php$pageselect = $_POST['TeamName'];?>[/code]And then dynamically update a <div> tage at the bottom of the page with that teams table (a .php doc stored under the team name) which I've written like so...[code] <?php if(ISSET($_POST['submitted'])){ include($pagename.php); }else{ echo "Please use the dropdown menu above to select your team name";} ?>[/code]As the error I'm getting is: The requested URL /$pageselect was not found on this server. I'm guessing either my team name is not getting passed across from my form or my include is wrong. Neither my php book or my html book have a simliar scenario that I can work from. Any suggestions? Other than maybe I should take up knitting or playing with kittens. Link to comment https://forums.phpfreaks.com/topic/28890-using-a-form-to-specify-include-location/ Share on other sites More sharing options...
kenrbnsn Posted November 29, 2006 Share Posted November 29, 2006 Your problem is here:[code]<form action="$pageselect" method="post" name="TeamName" id="TeamName">[/code]The value for the action attribute should be the name of script that processes the information from the form.Ken Link to comment https://forums.phpfreaks.com/topic/28890-using-a-form-to-specify-include-location/#findComment-132291 Share on other sites More sharing options...
Simplicity Posted November 29, 2006 Author Share Posted November 29, 2006 As[code]<?php$pageselect = $_POST['TeamName'];?>[/code] was originally included at the top of the page, I moved it to a new file named formhandle1.php and saved it.Changed my form to [code] <form action="formhandle1.php" method="post" name="TeamName" id="TeamName">[/code]Left everything else as is, (my 'if' statement remaining in the original <div> tag on the page under the form)When clicking submit I now just get a blank page. :( Link to comment https://forums.phpfreaks.com/topic/28890-using-a-form-to-specify-include-location/#findComment-132297 Share on other sites More sharing options...
sw0o0sh Posted November 29, 2006 Share Posted November 29, 2006 Seems as though your doing something difficult for an easy task.Say your form is on a page that has already included a file..Make this form..<form method='post'> <select name='teamname'> <option value='bla'>Bla</option> </select><br /><input type='submit' name='changepage' value='GO to Whatever' /></form>Now edit wherever it is in the page that is including a file to this:[code]if($_POST['changepage']){ include($_POST[teamname]."php");}else{ include('default_include.php');}[/code] Link to comment https://forums.phpfreaks.com/topic/28890-using-a-form-to-specify-include-location/#findComment-132311 Share on other sites More sharing options...
Simplicity Posted November 29, 2006 Author Share Posted November 29, 2006 Thanks.I think that almost worked. :)Warning: main(Unionistphp): failed to open stream: No such file or directory in etc etc referring to line 57 which reads[code] include($_POST[TeamName]."php");[/code]Its not putting the dot between the filename and extension? Link to comment https://forums.phpfreaks.com/topic/28890-using-a-form-to-specify-include-location/#findComment-132323 Share on other sites More sharing options...
Jocka Posted November 29, 2006 Share Posted November 29, 2006 need a period in thatinclude($_POST[TeamName].".php"); Link to comment https://forums.phpfreaks.com/topic/28890-using-a-form-to-specify-include-location/#findComment-132325 Share on other sites More sharing options...
sw0o0sh Posted November 29, 2006 Share Posted November 29, 2006 [quote author=Simplicity link=topic=116744.msg475868#msg475868 date=1164834188]Thanks.I think that almost worked. :)Warning: main(Unionistphp): failed to open stream: No such file or directory in etc etc referring to line 57 which reads[code] include($_POST[TeamName]."php");[/code]Its not putting the dot between the filename and extension?[/quote]I am very sorry, jocka is correct:make it this, i messed up on the include stringif($_POST['changepage']){ include($_POST[teamname].".php");}else{ include('default_include.php');} Link to comment https://forums.phpfreaks.com/topic/28890-using-a-form-to-specify-include-location/#findComment-132329 Share on other sites More sharing options...
Simplicity Posted November 29, 2006 Author Share Posted November 29, 2006 You people are gods! :D *cries tears of joy*Thank you all. Link to comment https://forums.phpfreaks.com/topic/28890-using-a-form-to-specify-include-location/#findComment-132331 Share on other sites More sharing options...
sw0o0sh Posted November 29, 2006 Share Posted November 29, 2006 [quote author=Simplicity link=topic=116744.msg475876#msg475876 date=1164834638]You people are gods! :D *cries tears of joy*Thank you all.[/quote]Np! Your welcome. Link to comment https://forums.phpfreaks.com/topic/28890-using-a-form-to-specify-include-location/#findComment-132334 Share on other sites More sharing options...
Jocka Posted November 29, 2006 Share Posted November 29, 2006 i just corrected the dot, i'll give all credit to sw0o0sh .. glad he could help :P Link to comment https://forums.phpfreaks.com/topic/28890-using-a-form-to-specify-include-location/#findComment-132335 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.