Jump to content

Recommended Posts

<?php require_once('../Connections/connection.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$email = $HTTP_POST_VARS['Email'];
$sql ="SELECT * FROM users WHERE Email='$email'";
$query = mysql_query($sql);
$count = mysql_num_rows($query);
if ($count > 0) {
header("location: newuser.php?mess=Sorry this email has already been used. <br>Please try again with another email address");
} 
else {
////////////////////////////////////
//File upload script for the picture

$fullname = strtolower($HTTP_POST_VARS['FirstName'])."_".strtolower($HTTP_POST_VARS['LastName'])."_".strtolower($HTTP_POST_VARS['OtherNames']);
			 if (is_dir("../images/users/".$fullname)) {  // check if directory for this artist works and images exist 	
         }
         else {
               $ee2 = @mkdir ('../images/users/'.$fullname); // create the folder
         }

$uploaddir = "../images/users/$fullname/";
$uploadfile = $uploaddir . $_FILES['Picture']['name'];

if (move_uploaded_file($_FILES['Picture']['tmp_name'], $uploadfile)) {
$picture = $_FILES['Picture']['name'];
$picture = $fullname."/".$picture;
    
} else {
    print "Possible file upload attack!";
}
//end of file upload///////////////

  $insertSQL = sprintf("INSERT INTO users (ID, FirstName, LastName, OtherNames, Rank, PWord, Address, Email, Phone, SchoolID, Picture) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, '$picture')",
                       GetSQLValueString($HTTP_POST_VARS['ID'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['FirstName'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['LastName'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['OtherNames'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['Rank'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['PWord'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['Address'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['Email'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['Phone'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['SchoolID'], "int"));
                     
  mysql_select_db($database_connection, $connection);
  $Result1 = mysql_query($insertSQL, $connection) or die(mysql_error());

  $insertGoTo = "success.php?mess=New user was successfully added.";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}}

mysql_select_db($database_connection, $connection);
$query_users = "SELECT * FROM users";
$users = mysql_query($query_users, $connection) or die(mysql_error());
$row_users = mysql_fetch_assoc($users);
$totalRows_users = mysql_num_rows($users);

mysql_select_db($database_connection, $connection);
$query_school = "SELECT schools.ID, schools.Name FROM schools";
$school = mysql_query($query_school, $connection) or die(mysql_error());
$row_school = mysql_fetch_assoc($school);
$totalRows_school = mysql_num_rows($school);
?><?
if($_GET['cat'] == '1') {

}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The Third Eye</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style></head>

<body>
<table width="100%" border="0" cellspacing="5" cellpadding="5">
  <tr>
    <td valign="top">New User </td>
  </tr>
  <tr>
    <td><form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1">
      <p align="center"><?= $mess;?></p>
      <table align="center">
          <tr valign="baseline">
            <td nowrap align="right">First Name:</td>
            <td><input type="text" name="FirstName" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Last Name:</td>
            <td><input type="text" name="LastName" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Other Names:</td>
            <td><input type="text" name="OtherNames" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Rank:</td>
            <td><select name="Rank" id="Rank">
              <option>Please select a rank</option>
              <option>============</option>
                <option value="Administrator">Administrator</option>
                <option value="Teacher">Teacher</option>
                <option value="Parent">Parent</option>
                <option value="Student">Student</option>
              </select>
            </td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Password:</td>
            <td><input type="password" name="Password" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Address:</td>
            <td><input type="text" name="Address" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Email:</td>
            <td><input type="text" name="Email" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Phone:</td>
            <td><input type="text" name="Phone" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">School:</td>
            <td><select name="SchoolID">
                <?php
do {  
?><option value="<?php echo $row_school['ID']?>"><?php echo $row_school['Name']?></option>
                <?php
} while ($row_school = mysql_fetch_assoc($school));
  $rows = mysql_num_rows($school);
  if($rows > 0) {
      mysql_data_seek($school, 0);
  $row_school = mysql_fetch_assoc($school);
  }
?>
                          </select>
            </td>
          <tr>
          <tr valign="baseline">
            <td nowrap align="right">Picture:</td>
            <td><input name="Picture" type="file" id="Picture" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right"> </td>
            <td><input type="submit" value="Submit"></td>
          </tr>
        </table>
        <input type="hidden" name="ID" value="">
        <input type="hidden" name="MM_insert" value="form1">
      </form>
    </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($users);

mysql_free_result($school);
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.