...

View Full Version : Resolved Half of page missing



buggy
01-25-2010, 09:19 PM
If input is submited blank an error msg comes up but only half the page shows:


<!-- Top html -->

<?php
// Check if the user submitted this form
if($_POST['submit'])
{

// Change HTML code so hackers cant f*ck you over eg: < to &lt;
$_POST['input'] = htmlspecialchars($_POST['input']);

// Check if input field is blank

if (empty($_POST['input'])) {

die('Error msg!');
}
// Open the file in write mode
$handle = fopen("inc/$list","a");

// If successful
if ($handle) {
// Write to that handle the input submitted
fwrite($handle, $_POST['input'] . PHP_EOL);

// Close
fclose($handle);
}
?>

<p><?php echo $success;?></p>

<?php
}
else
{
?>

<!-- Form is here -->

<?php
}
?>

<!-- Bottom html -->

it stops at the end of error msg so Bottom half of the html is missing ...

seco
01-25-2010, 09:21 PM
try

if (isset($_POST['email'])) {


same for submit

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

buggy
01-25-2010, 09:48 PM
try

if (isset($_POST['email'])) {


same for submit

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

made no effect :( thanks anyway ...

kbluhm
01-25-2010, 09:51 PM
http://www.php.net/exit - die() is an alias for exit()

It's working as it should, what else did you expect?

What you should be doing is collecting error messages, in an array for instance... then display the layout with the expected output, modifying it if errors were collected:


<?php

$errors = array();

if ( ! isset( $_POST['input'] ) || empty( $_POST['input'] ) )
{
$errors[] = 'input is empty!';
}

?>
<html>
...
<?php if ( count( $errors ) ): ?>
Errors were detected:<br />
<?php echo implode( '<br />', $errors );
<?php else: ?>
Display page as expected...
<?php endif; ?>
...
</html>

buggy
01-25-2010, 10:14 PM
Thanks both of you but I got it sorted myself :)

kbluhm
01-25-2010, 10:34 PM
Oh... well then, forget what we said.

Why remove the original issue? What if someone else comes along with a similar problem? I wouldn't consider this your own personal support department, and I'm sure it gets annoying when the questions get redundant. ;)

I mean, the topics in these forums -- as well as many others like it -- are archived and crawled by search engines. I'll bet it's awesome to pull up a topic and see nothing but edit: Resolved!, and then a bunch of solutions that have no coherence.

buggy
01-26-2010, 07:33 AM
Oh... well then, forget what we said.

Why remove the original issue? What if someone else comes along with a similar problem? I wouldn't consider this your own personal support department, and I'm sure it gets annoying when the questions get redundant. ;)

I mean, the topics in these forums -- as well as many others like it -- are archived and crawled by search engines. I'll bet it's awesome to pull up a topic and see nothing but edit: Resolved!, and then a bunch of solutions that have no coherence.

Put problem back to the best of my ability for you ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum