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
https://forums.phpfreaks.com/topic/203347-white-screen/
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
https://forums.phpfreaks.com/topic/203347-white-screen/#findComment-1065335
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
https://forums.phpfreaks.com/topic/203347-white-screen/#findComment-1065342
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
https://forums.phpfreaks.com/topic/203347-white-screen/#findComment-1065346
Share on other sites

Archived

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

×
×
  • 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.