Grafische gevorderde |
|
Ik heb nu de volgende 2 dingen
register.php
<?php
require_once("error.inc.php");
if(IsSet($_POST['register'])) {
$userName = stripslashes($_POST['username']);
$firstName = stripslashes($_POST['first_name']);
$lastName = stripslashes($_POST['last_name']);
$mail = stripslashes($_POST['mail']);
$error->emptyFields($userName, $firstName, $lastName, $mail);
}
?>
<form action="" method="POST">
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<td>Username:</td>
<td><input type="tekst" name="username" maxlength="16" length="30" /></td>
</tr>
<tr>
<td>Firstname:</td>
<td><input type="tekst" name="first_name" maxlength="25" length="30" /></td>
</tr>
<tr>
<td>Surname:</td>
<td><input type="tekst" name="last_name" maxlength="25" length="30" /></td>
</tr>
<tr>
<td>E-mail address:</td>
<td><input type="tekst" name="mail" maxlength="25" length="30" /></td>
</tr>
<tr>
<td colspan="2"><button type="submit" name="register">Register</button></td>
</tr>
</table>
</form>
<?php require_once("error.inc.php"); if(IsSet($_POST['register'])) { $error->emptyFields($userName, $firstName, $lastName, $mail); } ?> <form action="" method="POST"> <table cellpadding="3" cellspacing="0" border="0"> <tr> <td>Username:</td> <td><input type="tekst" name="username" maxlength="16" length="30" /></td> </tr> <tr> <td>Firstname:</td> <td><input type="tekst" name="first_name" maxlength="25" length="30" /></td> </tr> <tr> <td>Surname:</td> <td><input type="tekst" name="last_name" maxlength="25" length="30" /></td> </tr> <tr> <td>E-mail address:</td> <td><input type="tekst" name="mail" maxlength="25" length="30" /></td> </tr> <tr> <td colspan="2"><button type="submit" name="register">Register</button></td> </tr> </table> </form>
error.inc.php
<?php
class error_handling {
function emptyFields($name, $last, $first, $mail) {
if(empty($name) || empty($last) || empty($first) || empty($mail)) {
print("You haven't filled in all information:");
if(empty($name)) {
print("<br />- Username is empty");
}
if(empty($last)) {
print("<br />- Surname is empty");
}
if(empty($first)) {
print("<br />- Firstname is empty");
}
if(empty($mail)) {
print("<br />- E-Mail address is empty");
}
}
}
}
$error = new error_handling;
?>
<?php class error_handling { function emptyFields($name, $last, $first, $mail) { print("You haven't filled in all information:"); print("<br />- Username is empty"); } print("<br />- Surname is empty"); } print("<br />- Firstname is empty"); } print("<br />- E-Mail address is empty"); } } } } $error = new error_handling; ?>
Nu wil ik zorgen dat de error(s) op een nieuwe pagina komen. Dus zeg maar dat hij met een fout naar error.php gaat en dat hij dan alle foute laat zien die gemaakt zijn. Is dit mogelijk om te verwezenlijken?
En dan krijg je weer dat als je een error hebt dat hij dan naar register.php?act=error gaat, maar dan dus eigenlijk error.php laadt.
|