Jump to content

Undefined variable but how


vipsa

Recommended Posts

Hi 

 

I am a newbie. I get an error undefined variable subject and it is the line in the form where subject is but how can the variable be undefined if I define it in the beginning? Why then is the other variable $text also then not undefined.

 

I also get allot of css code in the form

<?php
if(!isset($_POST['submit'])) {
$from = 'corne@viprojects.net';
$subject = $_POST['subject'];
$text = $_POST['emailbody'];
$output_form = false;
 
if(empty($subject) && empty($text)) {
  echo 'You forgot the subject and text';
  }
$output_form = true;
if(empty($subject) && !empty($text)) {
  echo 'You forgot to enter the subject';
  }
  $output_form = true;
if(!empty($subject) && empty($text)) {
  echo 'You forgot to enter the text';
  }
  }
  else {
  $output_form = true;
  }
 
  if($output_form) {
    ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
      <label for="subject">Subject</label><br>
      <input type="text" id="subject" name="subject" value="<?php echo $subject; ?>"><br>
      <label for="emailbody">Email body</label><br>
      <textarea id="emailbody" name="emailbody" rows="5" cols="20" ><?php echo $text; ?></textarea><br>
      <input type="submit" name="submit" value="submit">
    </form>'
<?php
        }
?>
Edited by vipsa
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.