Created
September 4, 2009 21:10
-
-
Save anonymous/181134 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function exception_handler($exception) { | |
echo $exception->getMessage(); | |
} | |
set_exception_handler('exception_handler'); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Form { | |
function validateName($name){ | |
if(!$name || strlen($name) == 0){ | |
throw new Exception("Feltet er tomt!"); | |
return 1; | |
} | |
else | |
return 0; | |
} | |
function validateEntry($entry){ | |
if(!$entry || strlen($entry) == 0){ | |
return 1; | |
} | |
else | |
return 0; | |
} | |
} | |
$form = new Form(); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include("include/form.php"); | |
include("include/errors.php"); | |
class Process { | |
function Add($name, $entry){ | |
global $form; | |
$validateName = $form->validateName($name); | |
$validateEntry = $form->validateEntry($entry); | |
$Validate = $validateName+$validateEntry; | |
if($Validate == 0){ | |
//$sql->AddToDB($subName, $subAge, $subCity); | |
header("Location: index.php"); | |
} | |
else { | |
header("Location: opret.php"); | |
} | |
} | |
} | |
$process = new Process(); | |
if(isset($_POST['Add'])){ | |
$process->Add($_POST['name'], $_POST['entry']); | |
} | |
?> | |
<form action="" method="post"> | |
<label for="name">Navn: </label><br /> | |
<input type="text" name="name" id="name" /><br /> | |
<label for="entry">Indlæg: </label><br /> | |
<textarea name="entry" id="entry" cols="30" rows="9"></textarea> | |
<input type="hidden" name="Add" value="1" /> | |
<br /><br /> | |
<input type="submit" value="Send!" /> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment