phpanon Posted March 20, 2008 Share Posted March 20, 2008 Hi Everyone, My error messages are not appearing?!?!? <?php session_start(); if (isset($_SESSION['username']) == false){ header("Location: login.php"); exit(); } if (($_SESSION['type']) == 'user') { header("Location: AccessDenied.php"); exit(); } if (($_SESSION['type']) == 'manager') { header("Location: AccessDenied.php"); exit(); } require "connect.php"; $page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : ''; if ($page_mode == 'userADD') { $title = $_POST['title']; $fName = $_POST['fName']; $sName = $_POST['sName']; $jobRole = $_POST['jobRole']; $username = $_POST['username']; $password = $_POST['password']; $type = $_POST['type']; if($title == "Title") { $message1 = "Error: Please select the employees title"; } if($fName == "") { $message2 = "Error: Please enter the employees first name"; } if($sName == "") { $message3 = "Error: Please enter the employees surname"; } if($jobRole == "") { $message4 = "Error: Please enter the employees job role"; } if($username == "") { $message5 = "Error: Please enter the employees Username"; } if($password == "") { $message6 = "Error: Please enter the employees Password"; } if($type == "Access") { $message8 = "Error: Please enter the employees access level"; } if (is_numeric($fName)) { $message9 = "Error: Please ensure the Users firstname does not contain numbers"; } if (is_numeric($sName)) { $message10 = "Error: Please ensure the Users surname does not contain numbers"; } if (is_numeric($jobRole)) { $message11 = "Error: Please ensure the Users job role does not contain numbers"; } if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $username)) { $message13 = "Error: Please ensure the username is the persons email address"; } else if($title == !null || $fName == !null || $sName == !null || $jobRole == !null || $username == !null || $password == !null) { $username = mysql_real_escape_string($username); // protect against SQL attacks $fName = mysql_real_escape_string($fName); $sName = mysql_real_escape_string($sName); $jobRole = mysql_real_escape_string($jobRole); $query = "insert into employee values ('','".$title."','".$fName."','".$sName."','".$jobRole."','".$username."','".$password."', '".$type."','y')"; $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); $message7 = "The User ". basename ($_POST['fName']). "added successfully. "; header("Location: UserADD.php?message7=$message7"); exit(); } } ?> <!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 User</title> <link rel="stylesheet" type="text/css" href="mystylelogin.css" /> <style type="text/css"> <!-- .style1 {color: #FF0000} --> </style> </head> <body> <?php include ("headerAdmin.php"); ?> <div id="Adminheader">Create User</div> <form action="userADD2.php" method="post"> <input type="hidden" name="page_mode" value="userADD"> <div id="AdminTable"> <table width="99%" border="0"> <hr /> <tr> <td width="13%">Title:</td> <td width="34%"><select name="title"> <option >Title</option> <option >Mr</option> <option >Mrs</option> <option >Ms</option> <option >Miss</option> </select></td> <td width="8%"> </td> <td width="14%">Username:</td> <td width="17%"><input name="username" type="text" value="<?php if (isset($username)) echo $username;?>" /></td> <td width="14%"> </td> </tr> <tr> <td> </td> <td><span class="style2 style1"> <?php if(isset($_GET['message1'])) { echo $_GET['message1']; } ?> </span></td> <td> </td> <td colspan="3"><span class="style2 style1"> <?php if(isset($_GET['message5'])) { echo $_GET['message5']; } if(isset($_GET['message13'])) { echo $_GET['message13']; } ?> </span></td> </tr> <tr> <td>First Name:</td> <td><input name="fName" type="text" value="<?php if (isset($fName)) echo $fName;?>" /></td> <td> </td> <td>Password:</td> <td><input name="password" type="password" value="<?php if (isset($passwword)) echo $password;?>" /></td> <td> </td> </tr> <tr> <td> </td> <td><span class="style2 style1"> <?php if(isset($_GET['message2'])) { echo $_GET['message2']; } if(isset($_GET['message9'])) { echo $_GET['message9']; } ?> </span></td> <td> </td> <td colspan="3"><span class="style2 style1"> <?php if(isset($_GET['message6'])) { echo $_GET['message6']; } ?> </span></td> </tr> <tr> <td>Surname:</td> <td><input name="sName" type="text" value="<?php if (isset($sName)) echo $sName; ?>" /></td> <td> </td> <td>Access: </td> <td><select name="type"> <option >Access</option> <option >user</option> <option >admin</option> <option >manager</option> </select></td> <td> </td> </tr> <tr> <td> </td> <td><span class="style2 style1"> <?php if(isset($_GET['message3'])) { echo $_GET['message3']; } if (isset($_GET['message10'])) { echo $_GET['message10']; } ?> </span></td> <td> </td> <td colspan="3"><span class="style2 style1"> <?php if(isset($_GET['message8'])) { echo $_GET['message8']; } ?> </span></td> </tr> <tr> <td>Job Role:</td> <td><input type="text" name="jobRole" size="50" value="<?php if (isset($jobRole)) echo $jobRole; ?>" /></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><span class="style2 style1"> <?php if(isset($_GET['message4'])) { echo $_GET['message4']; } if(isset($_GET['message11'])) { echo $_GET['message11']; } ?> </span></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td><input name="Save" type="submit" value="Create User" /></td> <td> </td> </tr> <tr> <td> </td> <td><?php if(isset($_GET['message7'])) { echo $_GET['message7']; } ?></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> </div> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/97010-problems-with-error-messages/ Share on other sites More sharing options...
phpanon Posted March 20, 2008 Author Share Posted March 20, 2008 sorry solved!! Link to comment https://forums.phpfreaks.com/topic/97010-problems-with-error-messages/#findComment-496430 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.