Jump to content

Peterod

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Everything posted by Peterod

  1. I thought this was working but now i get an invalid augment. when i hit submit i nothing appeared to happen, the page returned was black so i did view source and there was the error. Could someone please double check the above code as I cant see whats wrong.
  2. what I actually want to do is take the username from the session, which is working now, thanks, and pit it into a form so that I can get different users to complete the form and i will know which user has done so. I will be able to figure that out now Thanks again guys.
  3. Hi All I have a basic login system on my site. How would I go about displaying the current logged in user information from the session Id. its quite confusing..... <?php require 'Mysql.php'; class Membership { function validate_user($un, $pwd) { $mysql = New Mysql(); $ensure_credentials = $mysql->verify_Username_and_Pass($un, ($pwd)); if($ensure_credentials) { $_SESSION['status'] = 'authorized'; header("location: ../selfbuild/Controlpanel.php"); } else return "Please enter a correct username and password"; } function log_User_Out() { if(isset($_SESSION['status'])) { unset($_SESSION['status']); if(isset($_COOKIE[session_name()])) setcookie(session_name(), '', time() - 1000); session_destroy(); } } function confirm_Member() { session_start(); if($_SESSION['status'] !='authorized') header("location: login.php"); } } Just need to display the user name at the moment but am kinda not getting how its done. Do I just need <?php session_start(); echo $un
  4. thanks sasa that's working now This is a work in progress whilst I am getting my head around php. I have more to add to the form but that will get me started on the principles of it all.
  5. heres the engine, as based on above. I only have a little spare time at night due to new baby so I dont get long to mess around with the site, so basically any help you guys give is 100% appreciated. <?php // make conn require_once "../classes/sqlconselfbuild.php"; foreach ($_POST['materials'] as $mater){ $name = $mater['name']; //or is it $id (not sure... anyone more help) $material = $mater['material']; $stage = $mater['stage']; $unit = $mater ['unit']; // satanize inputs mysql_query("UPDATE materials SET material='$material', stage='stage', quantity='quantity',unit='unit' WHERE id='$name'"); } ?> its live at the above address. I get a blank screen at the moment I think there are a few things wrong. please help update heres how i have it at the moment but still not working <?php // make conn $conn = require_once "../classes/sqlconselfbuild.php"; foreach ($_POST['materials'] as $mater){ $name = $mater['name']; //or is it $id (not sure... anyone more help) $material = $mater['material']; $stage = $mater['stage']; $unit = $mater ['unit']; // satanize inputs $sql = mysql_query("UPDATE materials SET material='$material', stage='stage', quantity='quantity',unit='unit' WHERE id='$name'"); } mysql_select_db('peterodc_selfbuild'); $retval = mysql_query( $sql,$conn); if(! $retval ) { die('Could not update data: ' . mysql_error()); } echo "Updated data successfully\n"; mysql_close($conn); } else { ?>
  6. I've read the php manual and a good few posts with similar but not identical problems and I am struggling to understand how to do this. Ive tailored my test site to help describe the problems that I have. www.peterod.co.uk the form is the first link in the left hand bar. Here is the code that creates the form. <?php // make connection require_once "../classes/sqlconselfbuild.php"; $query = mysql_query("SELECT * FROM `materials` ORDER BY `id` ASC"); ?> <form action="../engines/testengine1.php" method="post"> <?php // results while ($row = mysql_fetch_array($query)): $id = $row['id']; ?> <p> id number: <input type="text" name="materials[<?php echo $id; ?>][name]" value="<?php echo $row['id']; ?>" /> Material: <input type="text" name="materials[<?php echo $id; ?>][material]" value="<?php echo $row['material']; ?>" /> Stage: <input type="text" name="materials[<?php echo $id; ?>] [stage]" value="<?php echo $row['stage']; ?>" /> Qantity: <input type="text" name="materials[<?php echo $id; ?>][quantity]" value="<?php echo $row['quantity']; ?>" /> Unit: <input type="text" name="materials[<?php echo $id; ?>][unit]" value="<?php echo $row['unit']; ?>" /> <br /> </p> <?php endwhile; ?> <input type="submit" name="submit" value="Submit" /> </form> I am unsure how to get this information to insert into the database. How do you use the UPDATE query with a loop generated form ?
  7. still have questions on the above.... I want different users to submit seperate prices. how would you guys arrange the database. I have a table for materials and quantities, a table for users, a table for prices. so in the table for prices there will be a column for the userid and a column for the material id, and a column for price. This is all clear enough, but how do I query several tables and share data between them. I have the form above which will allow the merchants to post prices for each material (whilst showing the quantity's and material type that I have allready set up using a material control panel with forms for this.) It is difficult to ask the correct question when I have a few so many.... :-\ So... I will try again. I want the form above to only have an input field for price, which will insert the user name entered at a the login screen in the "price" table alongside the prices entered? Quite complicated but the final piece of this jigsaw for my application site. Not sure what other code I am using to let you guys see but would appreciate any further input that you can give me. I have learned a lot but still learning. I have the login system working, and the control panel displaying the database contents and allowing me to insert a data into the materials table. I can post that to my server and let you all see it working if that would help. Let me know if there is anything else i can say that will help you help me....
  8. Hi all. I am currently trying to build a site that will allow users to manage a self build house project. This is my first php MySQL project but I am getting to grips with it ok. I am currently building this for my own benefit at the moment as I am about to undertake a self build. I have a few questions to put to you guys. This is where I am at the moment I have a database table named materials which contains a list of materials , quantities, unit of measurement, id. My site has a user control panel that has separate forms for each stage of the build where the user enters the quantities of the materials, and the data is displayed as an array for each stage. So, heres question 1. I want to take the data and use it to generate a form which will be completed by several merchants.... so it will display similar to the array but will be a form with a text box for price where the merchant will insert a price. i.e <?php mysql_connect ("localhost", "test", "test") or die ('I cannot connect to the database becuase: ' . mysql_error()); mysql_select_db ("matquant"); // query $query = mysql_query("SELECT * FROM `quantites` ORDER BY `id` ASC"); // results while ($row = mysql_fetch_array($query)) { echo "<br />" .$row ['id']. " " .$row ['material']. " " .$row['quantity']. " " .$row['unit']. "<br />";} echo mysql_error(); ?> I want to add a text input box form which will allow the merchant to add a price to each item that is added to the array. so there the merchant will be able to give me a price for all the items in my list. Heres where I get stuck.... as I am constantly adding to the list I have no fixed amount of items so the form for the merchants needs to be built dynamically, ie each time I add a new material, I want the merchants form to get a new input. I am not very good at describing my problems but I am hoping that someone can help me out from the information given. Thats the first question. i like to get issues sorted in small bites. the second is the next big bite, I want to send the form above to several merchants, so I intend to have a user database with a user for each merchant, and link the tables so that each merchant can provide a price for each material, ideally the form would highlight the materials that have not had a price yet. I'm looking for advice on the best method of doing this basically but if I can get the first question sorted that would be great.. I have the test site local but can upload it it to the server if it will help you see what im trying to do. Any help that anyone can give will be greatly appreciated.
  9. thanks for that, its getting late lol. I am new to php and miss the obvious bits. Sorry about the crap original post. I will try to describe my problem better. I am simply trying to make a form that will update materials in a list. my page has the form on 1 side and the list on the right. I want to enter an ID in the first instance and then for the form to be populated with the data in the table with the id. I have 2 files . the form page and , ill call it the update engine.... The form page is below (between the horizontal rules. and throws the following errors on load. Notice: Undefined index: idtochange in C:\wamp\www\parkhall\changequanform.php on line 11 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\parkhall\changequanform.php on line 17 Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\parkhall\changequanform.php on line 31 [code=php:0]<?php mysql_connect("localhost","peter","tizer") or die("Error: ".mysqlerror()); mysql_select_db("matquant"); //replace TestTable with the name of your table //also in a real app you would get the id dynamically $idtochange=$_POST['idtochange']; // <<<<<<<<<<<<<<<<<<<<<<< line 11 $sql="select * from `quantites` where 'id' = $idtochange"; $query=mysql_query($sql); while ($row=mysql_fetch_array($query)){ $id = $row['id']; $material = $row['material']; $quantity = $row['quantity']; $unit = $row['unit']; //we will echo these into the proper fields } mysql_free_result($query); ?> <html> <head> <title>Edit material list</title> <link href="css/quant1.css" rel="stylesheet" type="text/css"> </head> <body> <div id="leftcol"> <form "method="post"> <p><br/> <input type="text"value="1" name="idtochange" /> <p> <input type="submit"value="submit changes"/> </form> <form action="changequan.php"method="post"> <p>Material Id currently active<br/> <input type="text"value="<?php echo $id;?>" name="id" disabled/> </p> <p> Enter new material name: </p> <input type="text"value="<?php echo $material;?>" name="material"/> <br/> change quantity: <input type="text"value="<?php echo $quantity;?>" name="quantity"/> <br/> unit of mesurement for quantity<br/> <input type="text"value="<?php echo $unit;?>" name="unit"/> <br/> </p> <input type="submit"value="submit changes"/> </form> </div> <div id="rightcol"><?php // make connection mysql_connect ("localhost", "peter", "tizer") or die ('I cannot connect to the database becuase: ' . mysql_error()); mysql_select_db ("matquant"); // build query $query = mysql_query("SELECT * FROM `quantites` ORDER BY `id` ASC"); // display results while ($row = mysql_fetch_array($query)) { echo "<br /> ..... " .$row ['id']. " ....... " .$row ['material']. " ...... " .$row['quantity']. " ...... " .$row['unit']. "<br />";} echo mysql_error(); ?> <a href="index.html">Home </a> <p> <a href="quanform.php">Insert new material and quantity form</a></p></div> </body> </html> [/code] Again, the errors on load of above.... to save scrolling Notice: Undefined index: idtochange in C:\wamp\www\parkhall\changequanform.php on line 11 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\parkhall\changequanform.php on line 17 Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\parkhall\changequanform.php on line 31 When I use the first form submit button, it works and updates the id for the second form section, and populates the text boxes with the data. this is the other file, the php for the formpage. <?php mysql_connect("localhost","peter","tizer") or die ("Error: ".mysqlerror()); mysql_select_db("matquant"); $id=$_POST['id']; $material=$_POST['material']; $quantity=$_POST['quantity']; $unit=$_POST['unit']; $sql="UPDATE `quantites` SET `material` = '$material',`quantity` = '$quantity',`unit` = '$unit' WHERE `quantites`.`id` = '$id' LIMIT 1"; mysql_query($sql)or die("Error: ".mysql_error()); echo"Database updated. <a href='changequanform.php'>Return to edit info</a>"; ?> It throws errors when I submit the second part of the form and I have just changes something and broken it further. Any help will be graciously recieved. Regards Peter
  10. heres the code... <?php mysql_connect("localhost","peter","tizer") or die("Error: ".mysqlerror()); mysql_select_db("matquant"); //replace TestTable with the name of your table //also in a real app you would get the id dynamically $idtochange=$_POST['idtochange']; $sql="select * from `quantites` where id = $idtochange"; $query=mysql_query($sql); while ($row=mysql_fetch_array($query)){ $id = $row['id']; $material = $row['material']; $quantity = $row['quantity']; $unit = $row['unit']; //we will echo these into the proper fields } mysql_free_result($query); ?> <html> <head> <title>Edit material list</title> <link href="css/quant1.css" rel="stylesheet" type="text/css"> </head> <body> <div id="leftcol"> <form "method="post"> <p><br/> <input type="text"value="1" name="idtochange" > <p> <input type="submit"value="submit changes"/> </form> <form action="changequan.php"method="post"> <p>Material Id currently active<br/> <input type="text"value="<?php echo $id;?>" name="id" disabled/> </p> <p> Enter new material name: </p> <input type="text"value="<?php echo $material;?>" name="material"/> <br/> change quantity: <input type="text"value="<?php echo $quantity;?>" name="quantity"/> <br/> unit of mesurement for quantity<br/> <input type="text"value="<?php echo $unit;?>" name="unit"/> <br/> </p> <input type="submit"value="submit changes"/> </form> </div> <div id="rightcol"><?php // make connection mysql_connect ("localhost", "peter", "tizer") or die ('I cannot connect to the database becuase: ' . mysql_error()); mysql_select_db ("matquant"); // build query $query = mysql_query("SELECT * FROM `quantites` ORDER BY `id` ASC"); // display results while ($row = mysql_fetch_array($query)) { echo "<br /> ..... " .$row ['id']. " ....... " .$row ['material']. " ...... " .$row['quantity']. " ...... " .$row['unit']. "<br />";} echo mysql_error(); ?> <a href="index.html">Home </a> <p> <a href="quanform.php">Insert new material and quantity form</a></p></div> </body> </html> I'm struggling with php. Any help anyone can give would be appreciated.
  11. didnt think of that. thanks a bunch. Solved
  12. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\parkhall\quantities.php on line 21 This is the error message. This is the code. simple array query to display contents of table and I cant see where i have made the mistake. hopefully someone can help. <?php mysql_connect ("localhost", "******", "*****") or die ('I cannot connect to the database becuase: ' . mysql_error()); mysql_select_db ("matquant"); $query = mysql_query("SELECT * FROM quantities"); while ($row = mysql_fetch_array($query)) { //line referred to in error message echo "<br /> ID: " .$row ['id']. " material : " .$row ['material']. "quantity:" .$row['quantity']. "<br />";} ?> Please point out the probably glaring error. I'm relatively new to this and I am really not finding php easy to learn.
×
×
  • 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.