Jump to content

PHP help loading new window from form


perezf

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]
Link to comment
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.
Link to comment
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]
Link to comment
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]
Link to comment
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!!!!';
}
Link to comment
Share on other sites

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.