jmr3460 Posted April 6, 2009 Share Posted April 6, 2009 I am learning PHP. I have a form page that uses PERL and it is a little complex (maybe just crowed). It is used to change the text at a specific location of a web page. Like I said I am learning PHP and need a little bit of information. If I knew what functions to look for I would be willing to do the foot work. There is a small issue with the form that I set up. I am using radio buttons to select the file to edit. This works great but the guy that is doing the editing has no real skills at all. He does not even know how to copy and paste. He clicked the wrong radio button and edited the wrong line. I was hoping to change to a multiple form setup using php to select the file then submit the first form which would open the second form with the file written into the <textarea> of the second form. Then he could make his edits then submit them writing the new information. This is some of the code I have now: <center> <h1>Edit the rows on the Home, Commercial, Residential, Security or Audio Video Pages</h1> <form method="POST" name="newtext" action="http://www.thesite.com/cgi-bin/edittext.cgi"> Please select one of the rows that is to be edited:<br/> <table> <tr> <td> <input type="radio" name="pageselect" value="commercialtext1"/> Commercial Text for row 1 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="commercialtext2"/> Commercial Text for row 2 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="commercialtext3"/> Commercial Text for row 3 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="commercialtext4"/> Commercial Text for row 4 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="commercialtext5"/> Commercial Text for row 5 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="commercialtext6"/> Commercial Text for row 6 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="commercialtext7"/> Commercial Text for row 7 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="commercialtext8"/> Commercial Text for row 8 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="commercialtext8"/> Commercial Text for row 9 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="commercialtext10"/> Commercial Text for row 10 </td> </tr> </table> I thought that I could just have the pageselect form select the file that would be placed into the edittext forms textarea using the include() inside the 2nd form. I am not sure how to bring the selected pageselect value to my second form. Can anyone help me. Thanks for any help, jmr3460 Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/ Share on other sites More sharing options...
jmr3460 Posted April 6, 2009 Author Share Posted April 6, 2009 I'm thinking that I can start here: $file = $_POST['pageselect']; //I think that this would select the value of the selected button If I do this can I use $file in the next form? Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-803012 Share on other sites More sharing options...
Maq Posted April 6, 2009 Share Posted April 6, 2009 Yes you can use $file, but you don't end your . Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-803014 Share on other sites More sharing options...
jmr3460 Posted April 6, 2009 Author Share Posted April 6, 2009 Are you saying that I can include the file I want to edit in one form by clicking the radio button I am looking to edit? How do I do that? Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-803018 Share on other sites More sharing options...
Maq Posted April 7, 2009 Share Posted April 7, 2009 I think I'm confused... How are these files stored? The radio button selected is the file that's going to be edited? If that's the case, then make the radiobuttons the paths to the files, so when you get to the next page you can just open up the value of the radio button. Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-803020 Share on other sites More sharing options...
jmr3460 Posted April 7, 2009 Author Share Posted April 7, 2009 I tend to confuse people that way. The files are stored as a .txt file in an includes folder. the radio button when selected takes the value and concatenates it with the .txt extension. Then I include the file to a web page. If I use the $text on the second form, can I include ($text.'.txt') in the textarea of that form? Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-803024 Share on other sites More sharing options...
Maq Posted April 7, 2009 Share Posted April 7, 2009 Yes, that looks like it should work, if your include directory is in the same directory as the file calling it. If not you would have to give it the relative path. Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-803027 Share on other sites More sharing options...
jmr3460 Posted April 7, 2009 Author Share Posted April 7, 2009 Thank you let me work with that and I will post my findings. Thanks again!!!!!!!!!!!!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-803030 Share on other sites More sharing options...
jmr3460 Posted April 7, 2009 Author Share Posted April 7, 2009 OK this is what I did. I created 2 forms on the same file. First form is for the pageselect. I created a varaible $pageselect: <?php $pageselect = $_POST['pageselect']; if(isset($_POST['pageselect'])) ?> I had this form echo $pageselect to the form below. <form method="POST" name="newtext" action="http://www.website.com/cgi-bin/edittext.cgi"> <input type="hidden" name="pageselect" value="<? echo $pageselect;?>" /> Now enter in the new text that you would like on your webpage. <br> If you would like to bold text,<br/> type <b> <b>at the beginning of what you would like to bold and then</b> </b><br/> at the end.<p> <textarea name="newtext" cols="70" rows="7" wrap="virtual"><? include($pageselect) ?></textarea> <p> <input type="submit" name="Submit"> <input type="reset" name="Clear Form"/> </form> I haven't tested the second form yet but I looked at it viewing the source through my browser and it looks like it will work. The only thing I don't know yet is if I can run perl from a .php file. That will be a question for tomorrow. Mag thanks for your help. I may not done it exactly the way I planned but I think it will solve the problem. I will check in tomorrow to check for any unforeseen issues someone may notice in my coding. I have learned on the fly reading Sams All in One and this site for information. Again Thanks Freaks Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-803182 Share on other sites More sharing options...
Maq Posted April 7, 2009 Share Posted April 7, 2009 The only thing I don't know yet is if I can run perl from a .php file. I haven't examined your code but you can run perl from PHP using shell_exec(). shell_exec("./script.pl"); Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-803480 Share on other sites More sharing options...
jmr3460 Posted April 8, 2009 Author Share Posted April 8, 2009 That is great it may take me another night or so to get this page working the way this guy wants it. Right now I have 74 radio buttons on one page and they work well except for the fact that there is a lot of scrolling down every time I check the page status. I am going to divide the page into about 5 categories just for aesthetics and ease of flow. I am getting a warning in my textarea until I set one of the radio buttons. That is minor at this point. I am having to get in touch with the hosting service for this guy so I can set my include folder to my ssi folder. I can't find the ini.php file so I can make those changes. They are telling me that I can put my own in the cgi-bin so I will have to fix that before I go any farther. Sorry for the long windedness. I am very tired I only got about 2 hours asleep last night and I need to find in right about now. I will work on the script and post what I get done hopefully tomorrow. I wish I did this for a living then I could do this right now. I will read up on the shell_exec(). This could be very helpful till I learn more about php. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-804196 Share on other sites More sharing options...
jmr3460 Posted April 10, 2009 Author Share Posted April 10, 2009 I guess I am going to have to rethink this issue. Network Solutions has issues letting me change my include folder. I can use the files that reside in the same folder that my script resides. Everything works good then, the only issue with that is I want to password protect the files in that folder. If I do that then I can't use the files in my apache includes. My question here is can I protect these files using PHP. I am thinking a page that uses I can use an if ... else statement. The folder is an admin setup that edits includes for the website. I will do some more studying!!! Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-806931 Share on other sites More sharing options...
jmr3460 Posted April 11, 2009 Author Share Posted April 11, 2009 I have my page working but I am getting a warning. What I have done is to include text from an include file. When I open the page as is the warning comes up in the textarea where I have included it. I can select the redio button and submit the file it works just like it is supposed to no errors at all. The warning only comes in when I open the page the first time or I refresh it. This is the code of my index page: <input type="radio" name="pageselect" value="interVactext18.html"/> Intercon/Vacuum Text for row 18 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="interVactext19.html"/> Intercon/Vacuum Text for row 9 </td> </tr> <tr> <td> <input type="radio" name="pageselect" value="interVactext20.html"/> Intercon/Vacuum Text for row 20 </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <table> <tr> <td> <input type="radio" name="pageselect" value="mainText.html"/> Main Page Text<br/> </td> </tr> </table> <?php $pageselect = $_POST['pageselect']; ?> <input type="submit" name="Submit" value="Enter Text from selected Row"> <input type="reset" name="Clear Form"/> </form> <form method="POST" name="newtext" action="http://www.ellendale-electric.com/cgi-bin/edittext.cgi"> <input type="hidden" name="pageselect" value="<?php echo $pageselect; ?>"/> Now enter in the new text that you would like on your webpage. <br> If you would like to bold text,<br/> type <b> <b>at the beginning of what you would like to bold and then</b> </b><br/> at the end.<p> <textarea name="newtext" cols="70" rows="7" wrap="virtual"><?php include $pageselect; ?></textarea> <p> <input type="submit" name="submit" value="Submit Text"> <input type="reset" name="Reset"/> </form> This is the warning that comes in the textarea: <br /> <b>Warning</b>: include() [<a href='function.include'>function.include</a>]: Failed opening '' for inclusion (include_path='/data/9/1/34/45/1197534/user/1275860/htdocs/ssi') in <b>/data/9/1/34/45/1197534/user/1275860/htdocs/admin/textEdit.php</b> on line <b>498</b><br /> Line 498 is my textarea line. Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-807043 Share on other sites More sharing options...
jmr3460 Posted April 12, 2009 Author Share Posted April 12, 2009 I am not sure exactly where I am on this forum as far as this topic but I have got this topic solved. I am still getting a warning on an include but at this time it is not much of a priority. I am going to mark this topic solved. Quote Link to comment https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/#findComment-808118 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.