Jump to content

Archived

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

perezf

PHP help loading new window from form

Recommended Posts

how do i get the following php code to work only when form is submitted
both php and html on same page

[code]<form name="form1" method="post" action="">
  <p align="center">
    <input type="submit" name="Submit" value="Preview">
    <br>
    <textarea name="practice" cols="100" rows="20"></textarea>
    </p>
</form>
<?php
$practice = $_POST['practice'];

if ($practice == NULL) {
echo 'empty';
}
else {
echo $practice;
}
?>[/code]

Share this post


Link to post
Share on other sites
[code]<form name="form1" method="post" action="">
<input type="hidden" name="gorgeusgeorge" value="1">
  <p align="center">
    <input type="submit" name="Submit" value="Preview">
    <br>
    <textarea name="practice" cols="100" rows="20"></textarea>
    </p>
</form>
<?php
$practice = $_POST['practice'];

if ($practice == NULL) {
echo 'empty';
}
elseif($gorgeusgeorge == '1') {
echo $practice;
}
?>[/code]

You could also uset isset but there are issues in IE with that.

Share this post


Link to post
Share on other sites
how would i use isset
for future reference

Share this post


Link to post
Share on other sites
[code]<form name="form1" method="post" action="">
  <p align="center">
    <input type="submit" name="Submit" value="Preview">
    <br>
    <textarea name="practice" cols="100" rows="20"></textarea>
    </p>
</form>
<?php
$practice = $_POST['practice'];

if ($practice == NULL) {
echo 'empty';
}
elseif(isset($_POST['Submit'])) {
echo $practice;
}
?>[/code]

Share this post


Link to post
Share on other sites
now how could i get the following to open a new window showing the text from the textarea box
[code]<form name="form1" method="post" action="">
  <p align="center">
    <input type="submit" name="Submit" value="Preview">
    <br>
    <textarea name="practice" cols="100" rows="20"></textarea>
    </p>
</form>
<?php
if(isset($_POST['Submit'])){
$practice = $_POST['practice'];

if ($practice == NULL) {
echo 'empty';
}
else {
echo $practice;
}}
else {
}
?>[/code]

Share this post


Link to post
Share on other sites
does anyone know how i can get this accomplished

Share this post


Link to post
Share on other sites
shouldnt the action value should be filled in and not empty like you have it there!
i think it should contain the filename that your sending the POST data to!
whether the practice variable contains something or not it is always send when you press submit.
so checking it with isset doesnt work i think.
if you dont want the form to show if you already send it, you should put it in a conditional statement.
if (empty($_POST['submit'])){
echo 'form and stuff';
}else{
echo 'show results!!!!';
}

Share this post


Link to post
Share on other sites

×

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.