Jump to content

lanceox

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by lanceox

  1. Thanks for your help in all but I may have confused you. what I would like Everything outputs great but can a table be included within the for loop so that no matter how many or few fields are printed; the size and availability will have its own row and column <table> Column 1 (simply to explain) Column2 (simply to explain) Size (own box) Availability 8-10 (own box) 34 (own box) 12-14 (own box) 34 (own box) 16-18 (own box) 34 (own box) 20-22 (own box) 34 (own box) </table> Thanks and again, sorry for confusion
  2. When I use this code it prints out array information. I changed it slightly (i.e. variables) and it only prints one size. The code is use is: <?php { echo'<pre>'; var_export($option_value['name'].' '.$option_value['quantity']); echo '</pre>'; } ?> The output i get is: '16 - 18 34' Thanks
  3. Hi, thanks for your answer. what I mean is that, at the moment the array prints out a products sizes (which can vary and also availability). So when considering the following code: <?php foreach ($option['option_value'] as $key => $option_value) { print ( '<pre>' ) ; print_r ($option_value['name'] .' '.$option_value['quantity']) ; print ( '</pre>' ) ; } ?> The for loop will print out all whatever the sizes and quantities are listed, however I would like it to add another row for any additional sizes. I think this should be within the for loop and print <new row> everytime $option_value['name'] is printed and then <new column then new row> everytime $option_value['quantity']). Size Availability 8-10 34 12-14 34 16-18 34 20-22 34 Hope this helps more Thanks guys
  4. Hi Thanks for the helps. This has put them in columns which i would like. Is there anyway that a table with rows and columns could be output aswell. For example below I have entered information (I know its wrong but just to try and explain what I mean) <table> <?php foreach ($option['option_value'] as $key => $option_value) { <tr> print ( '<pre>' ) ; print_r ($option_value['name'] .' '.$option_value['quantity']) ; print ( '</pre>' ) ; </tr> } ?> </table> I would like it to be output like this with cells, etc. Any form of really, just so that it will be output results in a table Size Availability 8-10 34 12-14 34 16-18 34 20-22 34 Thanks for all help so far
  5. Hey, I currently display the product options and the available quantity and everything works fine however I would like this information to be displayed in a table automatically (array form). This currently works using an array and outputs the information below. At the moment it looks like this: 8 - 10 12 - 14 16 - 18 34 34 34 However I would like it in table form, for example: Size Availability 8 - 10 34 12 - 14 34 16 - 18 34 <?php foreach ($option['option_value'] as $option_value) { print ( '<pre>' ) ; print_r ($option_value['name']); print ( '</pre>' ) ; } ?> <?php foreach ($option['option_value'] as $option_value) { print ( '<pre>' ) ; print_r ($option_value['quantity']); print ( '</pre>' ) ; } ?> If anyone could help that would be great. I have tried everything. If you need any further details please let me know
  6. it works there was a problem with the form and the it wasnt sending correct values. I echo'd out the values to see what wasnt working and corrected them Thanks for your help Lance
  7. Hey, i tried the way you said, however it still wont work, No errors occur however it just doesnt update the values in the database. Can someone have a look at see where i am going wrong. The form section <?php session_start(); ?> <!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=utf-8" /> <title>stock manager</title> </head> <body> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stockname" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stockqty" type="text" /> </td> </tr> </table> <input name="submit1" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockview.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); ?> <select name="stock"><option>Select Stock From List</option>";<?php while($row = mysql_fetch_array($result)) { echo "<option value=\"".$row[id]."\">".$row[stockname]."</option>"; } ?> </select> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> <BR /><BR /> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT stockname, stockqty FROM stocks"); $result = mysql_query ($query); echo "<table border='1'>"; echo "<tr><th>Stock Name</th> <th>Stock Quantity</th></tr>"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr><td>"; echo $row['stockname']; echo "</td>"; echo "<td>"; echo $row['stockqty']; echo "</td>"; } ?> </center> <table> <tr> <td> </td> <td> </td> </tr> </body> </html> The form handler section <?php session_start(); ?> <!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=utf-8" /> <title>stock</title> </head> <body> <?php $submit1 =&$_POST['submit1']; $stockname =&$_POST['stockname']; $stockqty =&$_POST['stockqty']; $submit =&$_POST['submit']; $stockqty1 =&$_POST['stock_qty1']; $id =&$_POST['stock']; if(isset($submit1)) { if(isset($stockname) && ($stockqty)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query = mysql_query("SELECT * FROM stocks WHERE stockname='$stockname'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo("Item already exists!");?><BR /><BR /><?php echo("Please Add A non-existent Item!");?> <a href="stockmanager.php">Try again!</a><?php } else { $queryreg = mysql_query("INSERT INTO `stocks` (stockname, stockqty) VALUES ('$stockname','$stockqty')"); echo("Stock has been added"); } } else { echo("Please fill in all fields to add stock!"); } } if(isset($submit)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); $sql = mysql_query("SELECT * FROM stocks WHERE id='$id'"); $numrows = mysql_num_rows($sql); $update = mysql_query("UPDATE stocks SET stockqty=$stockqty1 WHERE id=$id'"); echo("Item has been updated");?><BR /><BR /> <?php echo("Click here to return to stock manager!");?> <a href="stockmanager.php">Click Here!</a><?php } ?> </body> </html> Thanks Lance
  8. Hi guys, is it possible to update a field ina a database using a select box. So far i have populated the select box with database values and it works fine, however i dont know how to update the field properly in a database. have a look at the code and tell me what you think. <?php session_start(); ?> <!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=utf-8" /> <title>stock manager</title> </head> <body> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stockname" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stockqty" type="text" /> </td> </tr> </table> <input name="submit1" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockview.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); echo "<select name=stock value=''>Edit Stock QTY</option>"; while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } ?> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> <BR /><BR /> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT stockname, stockqty FROM stocks"); $result = mysql_query ($query); echo "<table border='1'>"; echo "<tr><th>Stock Name</th> <th>Stock Quantity</th></tr>"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr><td>"; echo $row['stockname']; echo "</td>"; echo "<td>"; echo $row['stockqty']; echo "</td>"; } ?> </center> <table> <tr> <td> </td> <td> </td> </tr> </body> </html> Here is the page that handles the form <?php session_start(); $_SESSION['nt']; $sn = $_SESSION['nt']; ?> <!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=utf-8" /> <title>stock</title> </head> <body> <?php $submit1 =&$_POST['submit1']; $stockname =&$_POST['stockname']; $stockqty =&$_POST['stockqty']; $submit = &$_POST['submit']; $stockqty1 = &$_POST['stock_qty1']; if(isset($submit1)) { if(isset($stockname) && ($stockqty)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query = mysql_query("SELECT * FROM stocks WHERE stockname='$stockname'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo("Item already exists!");?><BR /><BR /><?php echo("Please Add A non-existent Item!");?> <a href="stockmanager.php">Try again!</a><?php } else { $queryreg = mysql_query("INSERT INTO `stocks` (stockname, stockqty) VALUES ('$stockname','$stockqty')"); echo("Stock has been added"); ?><BR /><BR /> <?php echo("Click here to return to stock manager!");?> <a href="stockmanager.php">Click Here!</a><?php } } else { echo("Please fill in all fields to add stock!"); } } if(isset($submit)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } $queryreg = mysql_query("SELECT * FROM stocks WHERE stockqty='$stockqty1'"); $numrows = mysql_num_rows($queryreg); $update = mysql_query("UPDATE stocks SET stockqty=$stockqty1 WHERE stockname=$sn'"); echo("Item has been updated"); } ?> </body> </html> Any help woul;d be really great, i ahve tried everything for days on end now Thanks Lance
  9. Everything works fine and the select box appears and i can choose options from the database, however when i enter a new quantity the values are not modified.... So is there something wrong with the actual insert statements Im not sure how to choose the value from the select field. Hope this makes more sense Thanks Lance
  10. Hi guys, i have a select box which has been populated with values from the database however i would like to be able to select the value from the select box and change the qty. <!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=utf-8" /> <title>stock manager</title> </head> <body> <?php $stockqty =&$_POST['stock_qty1']; ?> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stock_name" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockmanager.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); echo "<select name=stock value=''>Edit Stock QTY</option>"; while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } $queryreg = mysql_query("SELECT * FROM stocks WHERE stockqty='$stockqty'"); $numrows = mysql_num_rows($queryreg); $update = mysql_query("UPDATE stocks SET stockqty='$stockqty' WHERE stockname = '$stockname'"); echo("Its updated"); ?> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> </center> </body> </html> Any help would be greatly appreciated... ive been working on this for a while and cant seem to find the answer. Thanks Lance
  11. Hi guys, Im developing a stock system and so far new stock and can be added with the quantity, however im trying to update the stock by using a select box and selecting the type of stock and inputting a new qty. the form and everything is set up and i can select files from the database, however i dont know how to update files from a select box The code i got so far is <!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=utf-8" /> <title>stock manager</title> </head> <body> <?php $stockqty =&$_POST['stock_qty1']; ?> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stock_name" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockmanager.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); echo "<select name=stock value=''>Edit Stock QTY</option>"; while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } $queryreg = mysql_query("SELECT * FROM stocks WHERE stockqty='$stockqty'"); $numrows = mysql_num_rows($queryreg); $update = mysql_query("UPDATE stocks SET stockqty='$stockqty' WHERE stockname = '$stockname'"); echo("Its updated"); ?> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> </center> </body> </html> Any help would be greatly appreciated. Thanks Lance
  12. ive checked to see if it exists but for example when i got to add exactly the same stock name it just adds a new one rather than echoing an error message saying item already exists, please updata existing values. Thanks Lance
  13. thanks it worked better than the way i done it. Thanks Is there a way i can check if stock exists then print message otherwise add to db. This is the kind of thing i mean.... where am i going wrong ? $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query = mysql_query("SELECT * FROM stocks WHERE stockname=$stockname, stockqty=$stockqty"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo("Item already exists! Try Updating the items instead!"); } else { $queryreg = mysql_query("INSERT INTO `stocks` (stockname, stockqty) VALUES ('$stockname','$stockqty')"); echo("stock added!"); }
  14. hi guys hope some1 can help. im creating a system that will allow stock to be added to a database and modifed. However on the add section, nothing adds it only inputs a new id row in the database and the other fields are blank. Can anyone have a look for me This sections is the form handler once the user has input a stockname and stock qty <?php session_start(); ?> <!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=utf-8" /> <title>stock</title> </head> <body> <?php $stockname = &$_POST['stockname']; $stockqty = &$_POST['stockqty']; $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query = mysql_query("SELECT * FROM stocks WHERE stockname=$stockname, stockqty=$stockqty"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo("Item already exists! Try Updating the items instead!"); } else { $queryreg = mysql_query("INSERT INTO `stock` . `stocks` (`id`, `stockname`, `stockqty`) VALUES (NULL,'$stockname','$stockqty')"); echo("stock added!"); } ?> <center><table> <tr> <td> Stock_id </td> <td> Stock_name </td> <td> Stock_Qty </td> </tr> </table></center> </body> </html> Thanks Lance
  15. Thanks for advice. With a bit of shuffling the pages around it worked. Thanks for all the advice. Lance P.s my project is done now.... thanks to you
  16. I tried it and it still the same, i put the echo ("please log in") so i could see whether it submits or not but it never changes or no pages that require a username work. Any more suggestions would be great. Thanks again!
  17. I checked my num rows variable and its not echoing anything out. What do you think should be my next step? thanks
  18. Hi guys, I got a little bit of an issue. I have a register page, which works fine and submits to itsself, however i also have a login page which currently has no errors but doesnt allow any1 to log in. If some1 can see why that will be great, as this is causing so many issues. This is the last step i cant get past. Here is the code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Forensics E-learning Package</title> <script type="text/javascript" src="start.js"></script> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="toplinks"> </div> </div> <div id="menu"> <ul> <li><a class="selected" href="index.html">Home</a></li> <li><a href="index.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> <li><a href="member.php">Member Section</a></li> </ul> </div> <div id="content"> <div id="main"> <h1>Forensics E-Learning Package</h1><BR /></head> Login to the User Profiled E-Learning Course which is specifically aimed to raise awareness in computer forensics. <?php $submit =&$_POST['submit']; if(isset($submit)) { if($username && sha1($password)) { $username =&$_POST['username']; $password =&$_POST['password']; $_SESSION['$username'] = $username; $_SESSION['$password'] = sha1($password); $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("userlogin", $connect) or die("Couldn't find db"); //$con = mysql_connect('userscores.db.7767668.hostedresource.com','userscores','L3tt3r09'); //mysql_select_db('userscores', $con); $query = mysql_query("SELECT * FROM users WHERE username=' $username'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { //code to login while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; $dbscore = $row['score']; $dbdclty = $row['dclty']; $dbid = $row['id']; $dbnewdclty = $row['newdclty']; } $_SESSION['id'] = $dbid; $_SESSION['PreviousScore'] = $dbscore; $_SESSION['dclty'] = $dbdclty; $_SESSION['newdclty'] = $dbnewdclty; if ($username==$dbusername&&sha1($password)==$dbpassword) { $username==$dbusername; } else { echo ("Incorrect Password!"); } } else { echo("That user doesn't exist!"); } } else { echo("Please enter a username and password!"); } echo ("You Successfully Logged In!"); } else { ?><BR /><BR /><?php echo("Please Log In!"); } if ($submit) echo "Logged In Successfully!"; ?> <BR /><BR /> <form action='index.php' method='POST'> Username: <input type='text' name='username'><BR /> Password: <input type='password' name='password'><BR /> <input type='submit' value='Log In'> </form> <p><BR /><BR /> <a class="button" href='register.php'><span><button class="button" id="save">Register</button></span></a> </div> <div id="right"> <h2>Right Menu</h2> <div class="rightitem"> <ul> <li><a class="selected" href="index.html">Home</a></li> <li><a href="index.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> <li><a href="member.php">Members Area</a></li> <li><a href="contact.php">Leave Feedback</a></li> </ul> </div> </div> </div> <div class="clearbottom"></div> <div id="footer"></div></div> </body> </html> Thanks for any help Lance
  19. I changed some things around and built it all in one which is similar to the register page but i cant see where the problem is, it is either not pulling information from database or assigning it to variables correctly <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Forensics E-learning Package</title> <script type="text/javascript" src="start.js"></script> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="toplinks"> </div> </div> <div id="menu"> <ul> <li><a class="selected" href="index.html">Home</a></li> <li><a href="index.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> <li><a href="member.php">Member Section</a></li> </ul> </div> <div id="content"> <div id="main"> <h1>Forensics E-Learning Package</h1><BR /></head> Login to the User Profiled E-Learning Course which is specifically aimed to raise awareness in computer forensics. <BR /><BR /> <form action='index.php' method='POST'> Username: <input type='text' name='username'><BR /> Password: <input type='password' name='password'><BR /> <input type='submit' value='Log In'> </form> <p><BR /><BR /> <a class="button" href='register.php'><span><button class="button" id="save">Register</button></span></a> <?php $submit =&$_POST['submit']; if($submit) { if($username && sha1($password)) { $username =&$_POST['username']; $password =&$_POST['password']; $_SESSION['$username'] = $username; $_SESSION['$password'] = sha1($password); $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("userlogin", $connect) or die("Couldn't find db"); //$con = mysql_connect('userscores.db.7767668.hostedresource.com','userscores','L3tt3r09'); //mysql_select_db('userscores', $con); $query = mysql_query("SELECT * FROM users WHERE username=' $username'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { //code to login while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; $dbscore = $row['score']; $dbdclty = $row['dclty']; $dbid = $row['id']; $dbnewdclty = $row['newdclty']; } $_SESSION['id'] = $dbid; $_SESSION['PreviousScore'] = $dbscore; $_SESSION['dclty'] = $dbdclty; $_SESSION['newdclty'] = $dbnewdclty; if ($username==$dbusername&&sha1($password)==$dbpassword) { $username==$dbusername; } else { echo ("Incorrect Password!"); } } else { echo("That user doesn't exist!"); } } else { echo("Please enter a username and password!"); } echo ("You Successfully Logged In!"); } else { //echo("Problem Logging In!"); } ?> </div> <div id="right"> <h2>Right Menu</h2> <div class="rightitem"> <ul> <li><a class="selected" href="index.html">Home</a></li> <li><a href="index.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> <li><a href="member.php">Members Area</a></li> <li><a href="contact.php">Leave Feedback</a></li> </ul> </div> </div> </div> <div class="clearbottom"></div> <div id="footer"></div></div> </body> </html> thanks for all your help so far lance
  20. Okay ill give that a go and try and implement it myself and ill be back to let you know. Thanks again Lance
  21. hey, This is a much harder way of doing things. The best thing to do is use sessions, when you understand them, they are much easier than cookies. have a look at this tutorial on building registration form, inserting the data to a database and then the oher parts look at creating a login page. if you need specific help then get back in touch but this might work better as this tells you how to do.
  22. Thanks for quick replies. I changed the echo so its before, however its still the same. I tried meta tags and i dont really want to use meta as this will show the message to the user however when they login it will also show member content for example. any more ideas will be great
  23. ahh right okay, tried using die() as i couldnt think of a way around the problem but the user to be redirected to the previous page if login details are incorrect but display a message. Whenever i redirect the message wont display. This is the code if any needs to see <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Forensics E-learning Package</title> <script type="text/javascript" src="start.js"></script> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="toplinks"> </div> </div> <div id="menu"> <ul> <li><a class="selected" href="index.html">Home</a></li> <li><a href="index.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> <li><a href="member.php">Member Section</a></li> </ul> </div> <div id="content"> <div id="main"> <h1>Forensics E-Learning Package</h1><BR /></head> Login to the User Profiled E-Learning Course which is specifically aimed to raise awareness in computer forensics. <BR /><BR /> <form action='login.php' method='POST'> Username: <input type='text' name='username'><BR /> Password: <input type='password' name='password'><BR /> <input type='submit' value='Log In'> </form> <p><BR /><BR /> <a class="button" href='register.php'><span><button class="button" id="save">Register</button></span></a> </div> <div id="right"> <h2>Right Menu</h2> <div class="rightitem"> <ul> <li><a class="selected" href="index.html">Home</a></li> <li><a href="index.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> <li><a href="member.php">Members Area</a></li> <li><a href="contact.php">Leave Feedback</a></li> </ul> </div> </div> </div> <div class="clearbottom"></div> <div id="footer"></div></div> </body> </html> page that checks the login information <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Forensics E-learning Package</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="toplinks"> </div> </div> <div id="menu"> <ul> <li><a class="selected" href="home.html">Home</a></li> <li><a href="initialquiz.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> <li><a href="evidencemodule.php">Evidence Module</a></li> </ul> </div> <div id="content"> <div id="main"> <h1>Forensics E-Learning Package</h1><BR /> <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; $_SESSION['$username'] = $username; $_SESSION['$password'] = sha1($password); if($username && sha1($password)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("userlogin") or die("Couldn't find db"); //$con = mysql_connect('userscores.db.7767668.hostedresource.com','userscores','L3tt3r09'); //mysql_select_db('userscores', $con); $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { //code to login while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; $dbscore = $row['score']; $dbdclty = $row['dclty']; $dbid = $row['id']; $dbnewdclty = $row['newdclty']; } //$scores = $dbscore; //$query1 = mysql_query("SELECT * FROM scores"); //while ($row = mysql_fetch_assoc($query)) //{ //$dbscores = $row['scores']; //$dbid = $row['id']; //} // $num=mysql_numrows($query1); if ($username==$dbusername&&sha1($password)==$dbpassword) { $username==$dbusername; } else { header('Location: index.php'); echo "<script>alert(\"incorrect password!\");</script>"; } } else { header('Location: index.php'); echo("That user doesn't exist!"); } } else { header('Location: index.php'); echo("Please enter a username and password!"); } $_SESSION['id'] = $dbid; $_SESSION['PreviousScore'] = $dbscore; $_SESSION['dclty'] = $dbdclty; $_SESSION['newdclty'] = $dbnewdclty; ?> <h2>Welcome to the Computer Forensics e-Learning Package</h2><BR /><BR /> Hi <b><?php echo $username; ?></b> <BR /><BR /> <p><b>Traditional E-Learning Packages</b><BR /> <BR /> </p> <p> Traditional e-learning systems are typically informative systems and generally just present information to the user from page to page, which is followed by a final quiz, which tests your knowledge on the subject topic being learned. The main issues with traditional e-learning systems is that the information presented to the user is non-personalized and there is a general assumption that every learner is on the same page in terms of knowledge level. <br /> <br /> <b>The User Personalized Learning Package</b><BR /><BR /> User Personalization over comes issues with traditional e-learning systems through the use of user profiles, for example, rather than viewing information from slide to slide, the user must first take a quiz before hand. This will allow the user profiling component to calculate the score from the quiz and present the user with relevant learning material based upon the users results. <br /> <p> <p>Please take the test to receive personalized e-learning content by selecting a difficulty. <BR /><BR /> <table> <tr> <td> <form name="difficulty selection" method="POST" action="initialquiz.php"> <input type="radio" name="dclty" id="dcltya" value="1">Beginner<BR> <input type="radio" name="dclty" id="dcltyb" value="2">Intermediate<BR> <input type="radio" name="dclty" id="dcltyc" value="3">Expert<BR> <input type="submit" name="submitdclty" id="button" value="select a difficulty rating!" /> </form> <td> <tr> </table> <BR /> </div> <div id="right"> <h2>Right Menu</h2> <div class="rightitem"> <ul> <li><a class="selected" href="home.html">Home</a></li> <li><a href="initialquiz.php">Initial Quiz</a></li> <li><a href="about.php">About</a> </li> <li><a href="member.php">Members Area</a> </li> <li><a href="evidencemodule.php">Evidence Module</a></li> <li><a href="contact.php">Leave Feedback</a></li> <li><a href="logout.php">Logout</a> </li> </ul> <p> </p> </div><em></em> </div> </div> <div class="clearbottom"></div> <div id="footer"> <p id="legal"> </p> </div> </div> </div> </body> </html> Any help would be great. really stuck on this Thanks Lance
  24. Hi there, i have a login page that does checks for things like incorrect passwords, etc however as i cant use die function as it terminates the rest of my code i used header(location).... to send the user back. is there anyway i could get the password checks to work without terminating my code with die()???? Thanks Lance
  25. ahhh okay, however rather than storing this information through a text field I would like to do it so the user can click save button on the final page and the quiz information is stored onto the database. How could i do this? Thanks
×
×
  • 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.