Jump to content

matrixbegins

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    India

matrixbegins's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello Everybody !! There is a functionality that I want in application. ................. Suppose a User uploads some files e.g images, Resumes etc. with proper info. like skills, experience etc. I mean some input in HTML controls. I want The moment user submits all data he/she should get a dynamically generated page showing a confirmation page then. I mean a preview page that show what user has inputted are all entries are OK or not. & then when user confirms the input then these values must saved in database. .................................... This far I have done. I want a little Favor .......... when user confirms all inputs that dynamically generated page must be saved as a static page on server in directory choose by me. Is this Possible or I am Just thinking Hypo.......... Please Help
  2. Thanks Mr. Aeglos Finally both example are working yours as well as mine. Many Thanks again. There was a blunder. I write it as $_SESSION["UserObj"] & I was trying to retreive it as $user=$_SESSION["userObj"] many thanks,
  3. Thanks Mr. Aeglos But I regret to say that its not working. whether $user=new ClassDemo(); is included or not. Some problem in system or something else. I have figured out another way If we can convert an object to equivalent array. i.e. an array indexed by class' attributes arr{ ['name']="XYZ" , ['Type']= "Paid" } Or something liike that. Can u give some Idea about this concept
  4. Here Is a simple Example That I used for demo. I used 5 files. 1.ClassDemo.php 2. script.php 3. pageHtml.php 4.Second.php 5. appfunctions.php ClassDemo.php <?php class ClassDemo{ private $user, $type; public function getUser(){ return $this->user; } public function setUser($user){ $this->user=$user; } public function getType(){ return $this->type; } public function setType($type){ $this->type=$type; } } ?> Now scripts.php <?php session_start(); include_once("ClassDemo.php"); include_once("appFunctions.php"); $user=$_POST["user"]; $type=$POST["type"]; $obj= new ClassDemo(); $obj->setUser($user); $obj->setType($type); $_SESSION["UserObj"]=$obj; redirect_to("Second.php"); ?> Now pageHtml.php <HTML> <BODY> <form name="form1" method="post" action="script.php"> <label>Email <input name="user" type="text" id="email" /> </label> <p> <label>Password <input name="type" type="text" id="pwd" /> </label> </p> <p> <label> <input type="submit" name="Submit" value="Login" /> </label> </p> </form> </BODY> </HTML> Second.html <?php session_start(); include_once("ClassDemo.php"); $user=new ClassDemo(); $user=$_SESSION["userObj"]; echo $user->getUser(); echo"<br>"; echo $user->getType(); ?> Now appFunctions.php <?php function redirect_to( $location = NULL ) { if ($location != NULL) { header("Location: {$location}"); exit; } } ?> Finally when I run this whole assembly I encountered with this error !! Fatal error: Call to a member function getUser() on a non-object in C:\wamp\www\demoapp\second.php on line 7. Now I think this simple to understand. One more thing First I write second.php as <?php session_start(); $user=$_SESSION["userObj"]; echo $user->getUser(); echo"<br>"; echo $user->getType(); ?> But I got Same error !! Please Help me out
  5. Thanks Mr. Well this was the that we can implement in Java. So how can Pass one object from one layer to another. <?php Line1 ::: $info=$info->getInfo($query); line 2 ::: if($info->getEmail()==$email) Line 3 :::$user=$_SESSION["thisuser"]; ?> in Line 1 getInfo($query) is function of class userInfo and returning an object of userInfo. So I think no problem with Line 1 if line1 is valid Line 2 will also execute as value of $email is retreived from a session variable which is used to keep track of user Authentication. For Line 3, I am fully aggreed to your view that objest is overwritten by Session variable. So if it is not working then There must be a way to Type cast a session varible into a desired datatype/ object. Can u suggest me something on thisconcept.
  6. Dear Mr. Mattcooper ! Here is some code. first I want u must take a look at directory structure. I just tried to MIMIC MVC Architecture but I'm not using any framework. Application |__app_code | |__Model | | |__HandleData.php | | |__LookupXml.php | | |__userInfo.php | | |__VabData.php. | | | |__Controller | |_chnginfo.php | |_getInfo.php | |_vabLogin.php | |__ pages |_ myHome.php DatasourceConfig.XML index.php Ok now when a user logs in from Index.php it is authenticated and redirected to myHome.php Here is code for userInfo.php <?php require_once("HandleData.php"); class userInfo{ private $email,$name,$sex,$dob,$country,$photourl,$skills; /*Email*/ public function getEmail(){ return $this->email; } public function setEmail($email){ $this->email=$email; } /*Name*/ public function getName(){ return $this->name; } public function setName($name){ $this->name=$name; } /*Sex*/ public function getSex(){ return $this->sex; } public function setSex($sex){ $this->sex=$sex; } /*DOB*/ public function getDob(){ return $this->dob; } public function setDob($dob){ $this->dob=$dob; } /*Country*/ public function getCountry(){ return $this->country; } public function setCountry($country){ $this->country=$country; } /*Photourl*/ public function getPhoto(){ return $this->photourl; } public function setPhoto($photourl){ $this->photourl=$photourl; } /*Skills*/ public function getSkills(){ return $this->skills; } public function setSkills($skills){ $this->skills=$skills; } /*userInfo*/ public function getInfo($str){ $user=new userInfo(); $data=new HandleData(); $arr=$data->select($str); if($arr){ $user->setEmail($arr['email']); $user->setName($arr['name']); $user->setSex($arr['sex']); $user->setDob($arr['dob']); $user->setCountry($arr['country']); $user->setPhoto($arr['photourl']); $user->setSkills($arr['skills']); } else{ $user->setEmail(NULL); $user->setName(NULL); $user->setSex(NULL); $user->setDob(NULL); $user->setCountry(NULL); $user->setPhoto(NULL); $user->setSkills(NULL); } return $user; } } Here is code for function HandleData->select($str) <?php include_once("VabData.php"); // [b]this is a class i have written a single function[/b] public function select($str){ $stmt=VabData::getConnection()->prepare($str); $stmt->execute(); return($stmt->fetch(PDO::FETCH_ASSOC)); } ?> Here is code for VabData::getconnection(); <?php include_once("LookXml.php"); class VabData{ private static $conn = null; // function to read XML file & get a connection public static function getConnection(){ $lookup=new LookXml(); $constr=$lookup->getConnectionString(); $user=$lookup->getUser(); $pass=$lookup->getPassword(); if(!self::$conn){ try{ self::$conn=new PDO($constr,$user,$pass); self::$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $ex){ echo "Error<br>"; echo"Sorry, an error has occurred. Please try your request later\n" . $ex->getMessage(); } } return self::$conn; } } ?> Now Take a look at getInfo.php <?php session_start(); include_once($_SERVER['DOCUMENT_ROOT']."vab/app_code/Model/userInfo.php"); require_once("appFunctions.php"); $email=$_SESSION['uid']; $query="SELECT * FROM userinfo WHERE email='{$email}'"; [b]$info=new userInfo();[/b] $info=$info->getInfo($query); if($info->getEmail()==$email) { $_SESSION['email']=$info->getEmail(); $_SESSION['name']=$info->getName(); $_SESSION['sex']=$info->getSex(); $_SESSION['dob']=$info->getDob(); $_SESSION['country']=$info->getCountry(); $_SESSION['skills']=$info->getSkills(); [b][/b] redirect_to("../../pages/profile.php"); } else{ $_SESSION['msg']="Error Loading Information from the Database"; redirect_to("../../pages/freeHome.php"); } ?> Rather Than doing so setting Too many session variables I tried to set The object of userInfo i.e. $info as $_SESSION["thisuser"]=$info; On the Html Page i.e. myHome.php I tried this <?php session_start(); include_once($_SERVER['DOCUMENT_ROOT']."vab/app_code/Model/userInfo.php"); $user=new userInfo(); $user=$_SESSION["thisuser"]; echo "Hello " echo $user->getEmail(); ?> It generates an error Now I think I have given almost all info. forgive me and ask for info that u want. Please Keep in mind this a beginner appraoch. Please State also that am I following a good practice. Please point out some pitfalls & drawbacks in my application design. ________________________________________________________________________________ With Warm Regards ANKUR
  7. Dear Mr. Rhodesa ! I have checked that care fully too. It will be more convinient to u if I give u some code? Thanks ANKUR
  8. Dear Mr. Rhodesa Thanks for ur great Help its working Just like I want Many thanks again, Ankur
  9. Hello Everybody! Can I use data transfer objects like JAVA BEANS of java in PHP. I'll illustrate my problem with my example. Here are Few Files that I use in my application: 1. DataHandler.php // a simple class that connects to database , closes connection, executes //insert/select/update/ delete queries. 2. UserInfo.php // a simple class that have some Getters/ setters methods for accessing a user's attributes. 3. ShowUserInfo.php // A simple file that authenticate & obtain data of a particular user. 4.MyHome.php // A simple view / HTML to show data. Now whenever a user logged in Showuser.php fetchs data and obtain an object of UserInfo Class, which have some attributes like username, phptoUrl, type(paid/free), Age etc. Now How ShowUserInfo.php must pass this object to MyHome.php so that it can used as a proper object there. In order to solve this I passed the object as a session variable as I have to use this object on some other pages too. But on reteriving Values e.g. obj->getUsername(); Php shows an error stating non_object method call or some thing like that. Please Help. Please tell me also that am I following a good practice or not. as I am new to PHP so I can't get into MVC framework yet. I well be very Obeliged if u could suggest a proper practice to use OOP. ______________________________________________ With Warm Regards Ankur
  10. Hello Everybody !! Thanks for devoting time. I am very new in php like an Infant. I have a Xml file Appsettings.xml like. <AppSettings> <images> <id>55</id> </images> </AppSettings> I can read this file By SimpleXML as follows: $content=simplexml_load_file("AppSettings.xml"); $imgid=$content->images->id; Now I want to read this value (images---> id i.e. 55) after some operations like increment by 1, I want to save this new value of the node in file too. that means the new value must reflect into xml file. I am Stucked with this problem. I tried dom but I got only help to create a new Xml File. Any way is this is possible? Please Help _____________________________________ With Warm Regards Ankur
×
×
  • 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.