Jump to content

white screen


el-sid

Recommended Posts

hi,

 

i get the following error when trying to render a form. I think it has to do with html content(header issue) though i'm not sure of how to reposition it

 

<?php

include ('../../lib/class.form.php');
include ('../../lib/Events.class.php');

session_start();

  if($_POST['submit']) {

    if(!empty($_POST['caption']) && !empty($_POST['content'])) {

        $event = new Events();

        $event->addEvent($_POST['caption'], $_POST['content'], $_POST['event_image']);

    }
    else {


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Add Event</title>
    </head>

    <body>
        <h1>Add Event</h1>

                <?php

                $form = new genForm();
                $form->startForm(basename($_SERVER['PHP_SELF']));

                $form->startFieldset('');
                $form->textInput('caption','Caption',false,'block required');
                $form->insertBR();

                $form->startFieldset('');
                $form->textareaInput('content','Event Details',false,'block');
                $form->insertBR();

                $form->startFieldset('');
                $form->fileInput('event_image','Upload Your Event Picture');
                $form->closeFieldset();
                $form->insertBR();

                $form->newline = false;
                $form->submitButton();
                $form->newline = true;
                $form->resetButton();

                $form->closeForm();

                if(!$output = $form->getForm()) {
                    die("error: " . $form->error);
                }
                else {
                    echo $output;
                }

                ?>
    </body>
</html>
        <?php

      
    }
}

?>

 

anyone knows what i'm missing?

Link to comment
Share on other sites

That will only echo the form, if it's been submitted

 

  if($_POST['submit']) {

    if(!empty($_POST['caption']) && !empty($_POST['content'])) {
blah blah

    }
    else {


// else it will echo the form

 

Is it intended to be like that?

 

Also, "i get the following error when trying to render a form". What error?

 

Link to comment
Share on other sites

That will only echo the form, if it's been submitted

 

  if($_POST['submit']) {

    if(!empty($_POST['caption']) && !empty($_POST['content'])) {
blah blah

    }
    else {


// else it will echo the form

 

Is it intended to be like that?

 

Also, "i get the following error when trying to render a form". What error?

 

thanks for the reply, the error was the white screen - sorry for the confusion. The form is meant to render only when there is no $_POST data

Link to comment
Share on other sites

Could try something like this:

 

<?php


include ('../../lib/class.form.php');
include ('../../lib/Events.class.php');

session_start();

  if(!isset($_POST['submit'])) {

        if(!empty($_POST['caption']) && !empty($_POST['content'])) {

            $event = new Events();

            $event->addEvent($_POST['caption'], $_POST['content'], $_POST['event_image']);

            }
  } else {


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Add Event</title>
    </head>

    <body>
        <h1>Add Event</h1>

                <?php

                $form = new genForm();
                $form->startForm(basename($_SERVER['PHP_SELF']));

                $form->startFieldset('');
                $form->textInput('caption','Caption',false,'block required');
                $form->insertBR();

                $form->startFieldset('');
                $form->textareaInput('content','Event Details',false,'block');
                $form->insertBR();

                $form->startFieldset('');
                $form->fileInput('event_image','Upload Your Event Picture');
                $form->closeFieldset();
                $form->insertBR();

                $form->newline = false;
                $form->submitButton();
                $form->newline = true;
                $form->resetButton();

                $form->closeForm();

                if(!$output = $form->getForm()) {
                    die("error: " . $form->error);
                }
                else {
                    echo $output;
                }

                ?>
    </body>
</html>
        <?php

      
    }
}

?>

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.