Jump to content

TheJoey

Members
  • Posts

    334
  • Joined

  • Last visited

    Never

Everything posted by TheJoey

  1. i dont know where to start and have tried many many scripts can anyone help me please.
  2. i dont know what to write to file. And how about to do it. im complety stuck on how to use this shopping cart,
  3. im having trouble writting to file. Note its XML im trying to write to <form name="thisForm" method="POST"> <ul> <li>Something old <a href="#" onclick="addToCart(1)">Add To Cart</a> (<?php if(isset($mycart->items["1"])) print $mycart->items["1"]; ?>)</li> <li>Something new <a href="#" onclick="addToCart(2)">Add To Cart</a> (<?php if(isset($mycart->items["2"])) print $mycart->items["2"]; ?>)</li> <li>Something borrowed <a href="#" onclick="addToCart(3)">Add To Cart</a> (<?php if(isset($mycart->items["3"])) print $mycart->items["3"]; ?>)</li> <li>Something blue <a href="#" onclick="addToCart(4)">Add To Cart</a> (<?php if(isset($mycart->items["4"])) print $mycart->items["4"]; ?>)</li> </ul> <input type="text" name="itemId"> <input type="text" name="qty" value="1"> <input type="hidden" name="cart" value="<?=$mycart->xml();?>"> </form> rest of code <?php require_once("ShoppingCart.php"); $mycart = new Cart("<items/>"); if (isset($_POST["cart"])) $mycart = new Cart($_POST["cart"]); if (isset($_POST["itemId"])) { $id = $_POST["itemId"]; if (isset($mycart->items[$id])) $mycart->items[$id] += $_POST["qty"]; else $mycart->add_item($_POST["itemId"], $_POST["qty"]); } ?> <html> <head> <script language="JavaScript"> function addToCart(id) { document.thisForm.itemId.value = id; document.thisForm.submit(); } </script> </head> <body> <form name="thisForm" method="POST"> <ul> <li>Something old <a href="#" onclick="addToCart(1)">Add To Cart</a> (<?php if(isset($mycart->items["1"])) print $mycart->items["1"]; ?>)</li> <li>Something new <a href="#" onclick="addToCart(2)">Add To Cart</a> (<?php if(isset($mycart->items["2"])) print $mycart->items["2"]; ?>)</li> <li>Something borrowed <a href="#" onclick="addToCart(3)">Add To Cart</a> (<?php if(isset($mycart->items["3"])) print $mycart->items["3"]; ?>)</li> <li>Something blue <a href="#" onclick="addToCart(4)">Add To Cart</a> (<?php if(isset($mycart->items["4"])) print $mycart->items["4"]; ?>)</li> </ul> <input type="text" name="itemId"> <input type="text" name="qty" value="1"> <input type="hidden" name="cart" value="<?=$mycart->xml();?>"> </form> </body> </html> <?php class Cart { var $items; // Items collection var $parser; var $cur_id; var $bIsID; var $bIsQty; function Cart($items_xml) { $this->bIsID = false; $this->bIsQty = false; $this->parser = xml_parser_create(); xml_set_object(&$this->parser, &$this); xml_set_element_handler(&$this->parser, array(&$this, "tag_open"), array(&$this, "tag_close")); xml_set_character_data_handler(&$this->parser, array(&$this, "cdata")); xml_parse(&$this->parser, &$items_xml); unset($this->cur_item); unset($this->bIsID); unset($this->bIsQty); } function tag_open($pparser, $tag, $attrs) { if ($tag == "ID") $this->bIsID = true; if ($tag == "QTY") $this->bIsQty = true; } function tag_close($pparser, $tag) { if ($tag == "ID") $this->bIsID = false; if ($tag == "QTY") $this->bIsQty = false; } function cdata($pparser, $data) { if ($this->bIsID) $this->cur_id = $data; if ($this->bIsQty) $this->items[$this->cur_id] = $data; } function add_item($id, $qty) { $this->items[$id] = $qty; } function update_qty($id, $qty) { $this->add_item($id, $qty); } function remove_item($id) { unset($this->items[$id]); } function xml() { $s = "<items>"; foreach($this->items as $key => $value) { $s .= "<item><id>" . $key . "</id><qty>" . $value . "</qty></item>"; } $s .= "</items>"; return $s; } } ?>
  4. I just some tutorials, or something i found an example on the internet but once i did get it running i found really hard to use. Any help is greatfull
  5. Is there a way where i can do on click add to file?
  6. fwrite($fp, $email."||".$fname."||".$lname."||".$age."||".$address."||".$city."\n"); that was my code when viewed in notepad it was on same line in wordpad in was viewed per line but when i do <?php readfile("text.txt"); ?> it views the same notepad
  7. When i try saving the files via fwrite it saves in a messy format. like Name,age,email,password then repeats on the same line even after /n
  8. its only for personal preferences. Theres no need for secruity. So there is no way to set permissions for windows? xammp
  9. im using windows and apache. How would i do so on this?
  10. Warning: file_put_contents(../logins/Joe/Joe_type_username.txt) [function.file-put-contents]: failed to open stream: No such file or directory in C:\xampplite\htdocs\Trial\Login\register\reg.php on line 14 Warning: file_put_contents(../logins/Joe/joe_type_password.txt) [function.file-put-contents]: failed to open stream: No such file or directory in C:\xampplite\htdocs\Trial\Login\register\reg.php on line 15 Warning: file_put_contents(../logins/Joe/joe_type_name.txt) [function.file-put-contents]: failed to open stream: No such file or directory in C:\xampplite\htdocs\Trial\Login\register\reg.php on line 16 Warning: file_put_contents(../logins/Joe/joe_type_email.txt) [function.file-put-contents]: failed to open stream: No such file or directory in C:\xampplite\htdocs\Trial\Login\register\reg.php on line 17 file_put_contents('../logins/'.$username.'/'.$username.'_type_username.txt', 'Done'); file_put_contents('../logins/'.$username.'/'.$password.'_type_password.txt', 'Done'); file_put_contents('../logins/'.$username.'/'.$name.'_type_name.txt', 'Done'); file_put_contents('../logins/'.$username.'/'.$email.'_type_email.txt', 'Done'); im working on putting into fwrite its just i find fwrite hard to work with due to recalling it
  11. well it makes it easier for me to proccess. At the moment its placing 4 files in logins folder. is there a way to make it so when "me" registers a folder in logins called "ME" is where the information is stored. Is there a way of putting all that info into one file. When i tried it messed up all my code because it was reading it wrongly.
  12. Placing information in a Seperate Directory for each register user. file_put_contents('../logins/'.$username.'_type_username.txt', 'Done'); file_put_contents('../logins/'.$password.'_type_password.txt', 'Done'); file_put_contents('../logins/'.$name.'_type_profilename.txt', 'Done'); file_put_contents('../logins/'.$email.'_type_profileemail.txt', 'Done'); So if user Me registers a folder me will be created thanks in advance
  13. ok ill have a play around with it ill keep you posted thanks for your help
  14. Can i do this threw fwrite or does it require something different? do you have a tut?
  15. Ok thanks for that. Its now adding 1 to each item, how would i store this information for later use? For like a checkout or order form. would i need to use a session start
  16. * Something old Add To Cart (items["1"])) print $mycart->items["1"]; ?>) * Something new Add To Cart (items["2"])) print $mycart->items["2"]; ?>) * Something borrowed Add To Cart (items["3"])) print $mycart->items["3"]; ?>) * Something blue Add To Cart (items["4"])) print $mycart->items["4"]; ?>) that is showing up when i run the code Where "Add to cart" is a link but it doesnt do anything. <?php class Cart { var $items; // Items collection var $parser; var $cur_id; var $bIsID; var $bIsQty; function Cart($items_xml) { $this->bIsID = false; $this->bIsQty = false; $this->parser = xml_parser_create(); xml_set_object(&$this->parser, &$this); xml_set_element_handler(&$this->parser, array(&$this, "tag_open"), array(&$this, "tag_close")); xml_set_character_data_handler(&$this->parser, array(&$this, "cdata")); xml_parse(&$this->parser, &$items_xml); unset($this->cur_item); unset($this->bIsID); unset($this->bIsQty); } function tag_open($pparser, $tag, $attrs) { if ($tag == "ID") $this->bIsID = true; if ($tag == "QTY") $this->bIsQty = true; } function tag_close($pparser, $tag) { if ($tag == "ID") $this->bIsID = false; if ($tag == "QTY") $this->bIsQty = false; } function cdata($pparser, $data) { if ($this->bIsID) $this->cur_id = $data; if ($this->bIsQty) $this->items[$this->cur_id] = $data; } function add_item($id, $qty) { $this->items[$id] = $qty; } function update_qty($id, $qty) { $this->add_item($id, $qty); } function remove_item($id) { unset($this->items[$id]); } function xml() { $s = "<items>"; foreach($this->items as $key => $value) { $s .= "<item><id>" . $key . "</id><qty>" . $value . "</qty></item>"; } $s .= "</items>"; return $s; } } ?> Shoppingcart.php <?php require_once("ShoppingCart.php"); $mycart = new Cart("<items/>"); if (isset($_POST["cart"])) $mycart = new Cart($_POST["cart"]); if (isset($_POST["itemId"])) { $id = $_POST["itemId"]; if (isset($mycart->items[$id])) $mycart->items[$id] += $_POST["qty"]; else $mycart->add_item($_POST["itemId"], $_POST["qty"]); } ?> <html> <head> <script language="JavaScript"> function addToCart(id) { document.thisForm.itemId.value = id; document.thisForm.submit(); } </script> </head> <body> <form name="thisForm" method="POST"> <ul> <li>Something old <a href="#" onclick="addToCart(1)">Add To Cart</a> (<? if(isset($mycart->items["1"])) print $mycart->items["1"]; ?>)</li> <li>Something new <a href="#" onclick="addToCart(2)">Add To Cart</a> (<? if(isset($mycart->items["2"])) print $mycart->items["2"]; ?>)</li> <li>Something borrowed <a href="#" onclick="addToCart(3)">Add To Cart</a> (<? if(isset($mycart->items["3"])) print $mycart->items["3"]; ?>)</li> <li>Something blue <a href="#" onclick="addToCart(4)">Add To Cart</a> (<? if(isset($mycart->items["4"])) print $mycart->items["4"]; ?>)</li> </ul> <input type="hidden" name="itemId"> <input type="text" name="qty" value="1"> <input type="hidden" name="cart" value="<?=$mycart->xml();?>"> </form> </body> </html> home.php
  17. $user_info = $email . "||" . $fname . "||" . $lname . "||" . $age . "||" . $address . "||" . $city . "\n" ; i want to print it on a seperate line but it doesnt seem to do it
  18. well my code is pretty similar to that just have to add explode functions and a few others. Once i serperate the info how i create a login?
  19. It doesnt seem to be storing to a file or anything. I dont know what im meant to do.
  20. correct its just something i want to try do. Is it possible?
  21. does anyone have a bit of code where i can work from.
  22. Ignore the above post i was missing the $ * Something old Add To Cart (items["1"])) print $mycart->items["1"]; ?>) * Something new Add To Cart (items["2"])) print $mycart->items["2"]; ?>) * Something borrowed Add To Cart (items["3"])) print $mycart->items["3"]; ?>) * Something blue Add To Cart (items["4"])) print $mycart->items["4"]; ?>) I think this is what is meant to be display but when i try clicking on the links i get nothing <?php class Cart { var $items; // Items collection var $parser; var $cur_id; var $bIsID; var $bIsQty; function Cart($items_xml) { $this->bIsID = false; $this->bIsQty = false; $this->parser = xml_parser_create(); xml_set_object(&$this->parser, &$this); xml_set_element_handler(&$this->parser, array(&$this, "tag_open"), array(&$this, "tag_close")); xml_set_character_data_handler(&$this->parser, array(&$this, "cdata")); xml_parse(&$this->parser, $items_xml); unset($this->cur_item); unset($this->bIsID); unset($this->bIsQty); } function tag_open($pparser, $tag, $attrs) { if ($tag == "ID") $this->bIsID = true; if ($tag == "QTY") $this->bIsQty = true; } function tag_close($pparser, $tag) { if ($tag == "ID") $this->bIsID = false; if ($tag == "QTY") $this->bIsQty = false; } function cdata($pparser, $data) { if ($this->bIsID) $this->cur_id = $data; if ($this->bIsQty) $this->items[$this->cur_id] = $data; } function add_item($id, $qty) { $this->items[$id] = $qty; } function update_qty($id, $qty) { $this->add_item($id, $qty); } function remove_item($id) { unset($this->items[$id]); } function xml() { $s = "<items>"; foreach($this->items as $key => $value) { $s .= "<item><id>" . $key . "</id><qty>" . $value . "</qty></item>"; } $s .= "</items>"; return $s; } } ?> <?php require_once("ShoppingCart.php"); $mycart = new Cart("<items/>"); if (isset($_POST["cart"])) $mycart = new Cart($_POST["cart"]); if (isset($_POST["itemId"])) { $id = $_POST["itemId"]; if (isset($mycart->items[$id])) $mycart->items[$id] += $_POST["qty"]; else $mycart->add_item($_POST["itemId"], $_POST["qty"]); } ?> <html> <head> <script language="JavaScript"> function addToCart(id) { document.thisForm.itemId.value = id; document.thisForm.submit(); } </script> </head> <body> <form name="thisForm" method="POST"> <ul> <li>Something old <a href="#" onclick="addToCart(1)">Add To Cart</a> (<? if(isset($mycart->items["1"])) print $mycart->items["1"]; ?>)</li> <li>Something new <a href="#" onclick="addToCart(2)">Add To Cart</a> (<? if(isset($mycart->items["2"])) print $mycart->items["2"]; ?>)</li> <li>Something borrowed <a href="#" onclick="addToCart(3)">Add To Cart</a> (<? if(isset($mycart ->items["3"])) print $mycart->items["3"]; ?>)</li> <li>Something blue <a href="#" onclick="addToCart(4)">Add To Cart</a> (<? if(isset($mycart->items["4"])) print $mycart->items["4"]; ?>)</li> </ul> <input type="hidden" name="itemId"> <input type="hidden" name="qty" value="1"> <input type="hidden" name="cart" value="<?=$mycart->xml();?>"> </form> </body> </html> Home.php im still getting this error after fixing it
  23. Yeh my provider are rubbish but ive got it now.. Thanks for the idea dj kat but ive already used some xml in my website already ive baised the website around using .txt files. im currently getting this website And thanks for the quick reply's guys Parse error: syntax error, unexpected ',', expecting T_PAAMAYIM_NEKUDOTAYIM in C:\xampplite\htdocs\Shopping Cart xml\ShoppingCart.php on line 17 For this code xml_set_character_data_handler(&$this->parser, array(&this, "cdata"));
  24. well its just personal preferences i guess, and my hosting charge for database.
×
×
  • 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.