el-sid Posted May 30, 2010 Share Posted May 30, 2010 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? Quote Link to comment Share on other sites More sharing options...
-Karl- Posted May 30, 2010 Share Posted May 30, 2010 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? Quote Link to comment Share on other sites More sharing options...
el-sid Posted May 30, 2010 Author Share Posted May 30, 2010 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 Quote Link to comment Share on other sites More sharing options...
-Karl- Posted May 30, 2010 Share Posted May 30, 2010 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 } } ?> Quote Link to comment Share on other sites More sharing options...
el-sid Posted May 30, 2010 Author Share Posted May 30, 2010 Thanks..it worked Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.