Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/152901-solved-select-and-write-to-file/
Share on other sites

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.

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?

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 &#60;b&#62; <b>at the beginning of what you would like to bold and then</b> &#60;&#47;b&#62;<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 

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.

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!!!

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 &#60;b&#62; <b>at the beginning of what you would like to bold and then</b> &#60;&#47;b&#62;<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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.