Jump to content

Trying to create hidden form-need help


jmr3460

Recommended Posts

I am trying to create a two part PHP form that will hide the second form until the first form is submitted. I am getting a warning on the second form because I do not have anything selected for the include() to include anything (i think). This is some snippets of the form:

<h1>Edit the rows on the Home, Commercial, Residential, Security or Audio Video Pages</h1>
<form method="POST" name="newtext" action="textEdit.php">
Please select one of the rows that is to be edited:<br/>

<table>
<tr>
	<td>
<table>
<tr>
	<td>
<input type="radio" name="pageselect" value="commercialtext1.html"/> Commercial Text for row 1
</td>
</tr>
<tr>
	<td>
<input type="radio" name="pageselect" value="commercialtext2.html"/> Commercial Text for row 2
</td>
</tr>
<tr>
	<td>
<input type="radio" name="pageselect" value="commercialtext3.html"/> Commercial Text for row 3
</td>
</tr>
<tr>
	<td>
<input type="radio" name="pageselect" value="commercialtext4.html"/> Commercial Text for row 4
</td>
</tr>
<tr>
	<td>
<input type="radio" name="pageselect" value="commercialtext5.html"/> Commercial Text for row 5
</td>
</tr>
<tr>
	<td>
<input type="radio" name="pageselect" value="commercialtext6.html"/> Commercial Text for row 6
</td>
</tr>
<tr>
	<td>
<input type="radio" name="pageselect" value="commercialtext7.html"/> Commercial Text for row 7
</td>
</tr>
<tr>
	<td>
<input type="radio" name="pageselect" value="commercialtext8.html"/> Commercial Text for row 8
</td>
</tr>
<tr>
	<td>
<input type="radio" name="pageselect" value="commercialtext8.html"/> Commercial Text for row 9
</td>
</tr>
<tr>
	<td>
<input type="radio" name="pageselect" value="commercialtext10.html"/> Commercial Text for row 10
</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.mysite.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>

 

I am trying to only echo (the second form)if submit (to the first form) isset. 

Link to comment
https://forums.phpfreaks.com/topic/158069-trying-to-create-hidden-form-need-help/
Share on other sites

Do this....

 

In your first form call the submit button something different like "submit1"...

<INPUT TYPE="SUBMIT" name="submit1" value="Enter Text from selected Row">

 

Then in php you can check to see if that form was submitted by doing this..

if (isset($_POST[submit1]))

 

You can check to see if it was NOT submitted by doing this...

if (!isset($_POST[submit1]))

 

You code should look something like this..

 

if (!isset($_POST[submit1]))
{
//display first form
}

else if (isset($_POST[submit1]))
{
//display second form
}

 

The above again is all assuming that you've changed your first form's submit button to..

<INPUT TYPE="SUBMIT" name="submit1" value="Enter Text from selected Row">

Thanks for your help on this. I am going to have to sleep on this. I have put the code at the end of the first form within PHP brackets and the second form is hidden. When I hit submit the first form then the page reloads only the second form is still hidden. I will have to retry this tomorrow. I am like a zombie right now. I am probable over looking something tonight.

Thanks again for your help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.