3 Replies - 275 Views - Last Post: 31 October 2013 - 01:42 PM Rate Topic: -----

#1 Hulu  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 17-July 13

Image Variable

Posted 31 October 2013 - 11:45 AM

When someone submits a form depending on the name of the item it will INSERTthe right image path so it will show on the home page. But it doesn't get to the INSERT part of the script.

<?php

class Account extends MainController{
	function __construct(){
			parent::__construct();
			if($_SESSION['user'] == ""){
				header("location:Logout");
				exit(0);
			}else{
				
				$sql = "SELECT * FROM users WHERE username = :username ";
				$arr = array(":username" => $_SESSION['user']);
				$ctr = $this->database->DBCtr($sql,$arr);
				
				if($ctr > 0){
					$usr = $this->database->DBQry($sql,$arr);
					$this->view->usr = $usr[0]['username'];
					$this->view->pss = $usr[0]['password'];
					$this->view->name = $usr[0]['user_id'];
				}else{
					header("location:Index");
					exit(0);
				}
				
			}
	}
	
	function ChangePassword(){
		$this->view->url	=	$this->config->url;
		$this->view->ID 	  = get_class($this);
		$this->view->Title = "Royal JD > Account > Change Password";
		$this->view->render('Account/ChangePassword');
	}
	
	function ChangePasswordSubmit(){
		
		$this->view->url	=	$this->config->url;
		$this->view->ID 	  = get_class($this);
		$this->view->Title = "Royal JD > Account > Change Password";
		
		$new = isset($_POST['new']) ? $_POST['new'] : '';
		$old = isset($_POST['old']) ? $_POST['old'] : '';
		$con = isset($_POST['con']) ? $_POST['con'] : '';
		$this->view->usr = mysql_real_escape_string(StrToLower(Trim($this->view->usr)));
		$new = mysql_real_escape_string(StrToLower(Trim($new)));

		$this->view->salt = $usr[0]['username'];
		$this->view->salt = $this->view->name.$new;
		$this->view->salt = md5($this->view->salt);
		$this->view->salt = "0x".$this->view->salt; //Salts the password in md5.
		$this->view->msg = "";
		$this->view->err = false;
		
		if($old != $this->view->pss){
			$this->view->msg = "Old Password is Incorrect";
		}elseif($new == ""){
			$this->view->msg = "New Password is Empty";
		}elseif($con != $new){
			$this->view->msg = "Please Confirm Password Correctly";
		}else{
			$arr = array(":idnumber" => $new, ":passwd" => $this->view->salt);
			$this->database->DBSet($arr,'users',$whr = 'WHERE ID = '.$add);
			$this->view->msg = "Password is Successfully Changed";
			$this->view->err = true;
		}
		
		$this->view->render('Account/ChangePasswordSubmit');
		
		
		
	}

	function AddItem(){
		$this->view->url	=	$this->config->url;
		$this->view->ID 	  = get_class($this);
		$this->view->Title = "D3 > Account > Add Item";
		$this->view->render('Account/AddItem');
	}

	function AddItemSubmit(){
		$this->view->url	=	$this->config->url;
		$this->view->ID 	  = get_class($this);
		$this->view->Title = "D3 > Account > Add Item";


		$itemName = $_POST['item_name'];
		$img = '';
		$Quality = $_POST['quality'];
		$Type = $_POST['type'];
		$subType = $_POST['sub'];
		$itemAttrib1 = $_POST['list_1'];
		$itemAttrib2 = $_POST['list_2'];
		$itemAttrib3 = $_POST['list_3'];
		$itemAttrib4 = $_POST['list_4'];
		$itemAttrib5 = $_POST['list_5'];
		$itemAttrib6 = $_POST['list_6'];
		$itemAttrib7 = $_POST['list_7'];
		$itemAttrib8 = $_POST['list_8'];
		$Value_1 = isset($_POST['val_1']) ? ($_POST['val_1']) : '';
		$Value_2 = isset($_POST['val_2']) ? ($_POST['val_1']) : '';
		$Value_3 = isset($_POST['val_3']) ? ($_POST['val_1']) : '';
		$Value_4 = isset($_POST['val_4']) ? ($_POST['val_1']) : '';
		$Value_5 = isset($_POST['val_5']) ? ($_POST['val_1']) : '';
		$Value_6 = isset($_POST['val_6']) ? ($_POST['val_1']) : '';
		$Value_7 = isset($_POST['val_7']) ? ($_POST['val_1']) : '';
		$Value_8 = isset($_POST['val_8']) ? ($_POST['val_1']) : '';

		$this->view->msg = "";
		$this->view->err = false;

		if ($itemName = "Ageless_Might"){
			$img = "unique_barbbelt_008_104_demonhunter_male.png";
		}elseif ($itemName == ""){
			$this->view->msg = "You must enter an item name!";
		}elseif ($Quality == "Any Quality"){
			$this->view->msg = "You must choose a quality!";
		}elseif ($Type == "Any Type"){
			$this->view->msg = "You must choose a type!";
		}elseif ($subType == "Any Subtype"){
			$this->view->msg = "You must choose a sub type!";
		}elseif (!ctype_digit($Value_1)){
			$this->view->msg = "You must enter a value";
		}else{
			$sql = "INSERT INTO `items_us_sc` (`item_num`, `item_name`, `quality`, `type`, `sub_type`, `attrib_1`, `value_1`, `attrib_2`, `value_2`, `attrib_3`, `value_3`, `attrib_4`, `value_4`, `attrib_5`, `value_5`, `attrib_6`, `value_6`, `attrib_7`, `value_7`, `attrib_8`, `value_8`, `item_img`) VALUES (NULL, '$itemName', '$Quality', '$Type', '$subType', '$itemAttrib1', '$Value_1', '$itemAttrib2', '$Value_2', '$itemAttrib3', '$Value_3', '$itemAttrib4', '$Value_4', '$itemAttrib5', '$Value_5', '$itemAttrib6', '$Value_6', '$itemAttrib7', '$Value_7', '$itemAttrib8', '$Value_8', '$img')";
			$arr = array();
			$ctr = $this->database->DBQry($sql,$arr);
			$this->view->msg = "Item Successfully Added!";
			$this->view->err = true;
		}

		$this->view->render('Account/AddItemSubmit');

	}
}
?>


I am running out of ideas here.

Is This A Good Question/Topic? 0
  • +

Replies To: Image Variable

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3467
  • View blog
  • Posts: 11,768
  • Joined: 12-December 12

Re: Image Variable

Posted 31 October 2013 - 12:53 PM

You need to provide more information, to assist anyone who might want to help you.

Anyway, this line:

if ($itemName = "Ageless_Might"){

is an assignment, rather than performing a comparison, so the other else-clauses will never be executed.

Mind you, if the line after that one:

$img = "unique_barbbelt_008_104_demonhunter_male.png";

isn't executed then the $img will still have its original, empty, value when attempting to insert it into the table.
Was This Post Helpful? 0
  • +
  • -

#3 Hulu  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 17-July 13

Re: Image Variable

Posted 31 October 2013 - 01:37 PM

Thank you for your response, I figured it out :) please close the thread
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3467
  • View blog
  • Posts: 11,768
  • Joined: 12-December 12

Re: Image Variable

Posted 31 October 2013 - 01:42 PM

Threads aren't generally closed, they have 'Ageless_Might' ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1