Jump to content


Photo

PHP help loading new window from form


  • Please log in to reply
6 replies to this topic

#1 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 10 August 2006 - 11:41 AM

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

<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;
}
?>


#2 Madatan

Madatan
  • Members
  • PipPipPip
  • Advanced Member
  • 51 posts

Posted 10 August 2006 - 11:45 AM

<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;
}
?>

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

#3 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 10 August 2006 - 11:48 AM

how would i use isset
for future reference

#4 Madatan

Madatan
  • Members
  • PipPipPip
  • Advanced Member
  • 51 posts

Posted 10 August 2006 - 11:54 AM

<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;
}
?>


#5 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 10 August 2006 - 12:28 PM

now how could i get the following to open a new window showing the text from the textarea box
<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 {
}
?>


#6 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 10 August 2006 - 01:00 PM

does anyone know how i can get this accomplished

#7 Silverado_NL

Silverado_NL
  • Members
  • PipPipPip
  • Advanced Member
  • 105 posts
  • LocationZaandam (Netherlands)

Posted 10 August 2006 - 01:07 PM

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!!!!';
}
The Force is like ductape, it has a light side, it has a dark side, and it combines the universe together!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users