Jump to content

alan6566

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Everything posted by alan6566

  1. Thanks for your help. It is working fine now just had to change one of the variable names. Now how can I submit this to an ordering table within my data base with the quanity they want?
  2. i am taking the advice. but it is not seeming to work. i just though that you may want to see the page where it is getiing sent from. and if you were going to design and ordering system how would you do it? as i have been stuck for days of this one thing.
  3. The page that sends the information to the page is bellow. If I get it just to display the value it works but when it displays i get it to diplay from the data base it does not work <? session_start(); if ($_SESSION['userName']) {} else { header('location:../index.php'); } ?> <!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>Deliver-Pizza Topping</title> <link href="css/pizza-topping.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <img src="images/logo.jpg" alt="logo" /> <a href="log-off.php" id="logg-off" >log off</a> <ul id="nav"> <li><a href="home.php" target="_self">Home</a></li> <span> | </span> <li><a href="Pizza-Topping.php" target="_self">Pizza Topping</a></li> <span> | </span> <li><a href="order.php" target="_self">Order</a></li> <span> | </span> <li><a href="Account.php" target="_self">Account Details</a></li> <span> | </span> </ul> </div> <div id="Featured"> <img src="images/banner1.jpg" alt="banner" name="banner"" ID="banner"></div><!--end Featured--> <div class="featuredimage" id="main"> <div id="content" class="tiles"> <h1>Pizza-Topping</h1><hr /> <p>The list bello are the pizzas available to order</p> <div id ="staff"><div style="width:920px; height:autopx; overflow:auto; heightmax:300px"> <left> <table> <tr> <th>pizza number</th> <th>Type</th> <th>Size</th> <th>Topping</th> <th>Cost</th> <th>Information</th> <th> <form name="pizza-order" action="order.php" method="post"><input type="submit" name="submit" Value="Order"></th> </tr> <tr> <?php mysql_connect("localhost", "root", "")or die("cannot connect"); mysql_select_db("deliverpizza")or die("cannot select DB"); $sql="SELECT * FROM `pizzatopping` "; $result= mysql_query($sql); while($row =mysql_fetch_assoc($result)) { ?> <td><?php echo $row['id'] ?></td> <td><?php echo $row['type'] ?></td> <td><?php echo $row['size'] ?></td> <td><?php echo $row['topping'] ?></td> <td><?php echo $row['cost'] ?></td> <td><?php echo $row['info'] ?></td> <td> <input type="checkbox" Name="pizza<?php echo $row['id'] ?>" value="<?php echo $row['id'] ?>" /> </td> </tr></left> <?php } ?> </table> </div> <!--<form name="pizza-order" action="order.php"> Pizza Number<input type="text" Name="pizza-1">Quanity<input type="text" Name="quanit-1y"><br/> Order 2<input type="text" name="order-2"><br/> <input type="submit" name="submit" Value="Order"> </form>--> </div> </div> </div> <!--end content--> <div id="footer"><span><p>Created By Ryan Williams</p></span></div><!--end footer--> </div><!--end container--> </body> </html>
  4. I am trying to get it to display the table where only some rows will be shown. It works on picking up each indivual value from the othere page but when it comes to displaying the table it only pics up the first value and only displays that. Here is my code bellow <? session_start(); if ($_SESSION['userName']) {} else { header('location:../index.php'); } ?> <!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>Deliver-Pizza Order</title> <link href="css/order.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <img src="images/logo.jpg" alt="logo" /> <a href="log-off.php" id="logg-off" >log off</a> <ul id="nav"> <li><a href="home.php" target="_self">Home</a></li> <span> | </span> <li><a href="Pizza-Topping.php" target="_self">Pizza Topping</a></li> <span> | </span> <li><a href="order.php" target="_self">Order</a></li> <span> | </span> <li><a href="Account.php" target="_self">Account Details</a></li> <span> | </span> </ul> </div> <div id="Featured"> <img src="images/banner1.jpg" alt="banner" name="banner"" ID="banner"></div><!--end Featured--> <div class="featuredimage" id="main"> <div id="content" class="tiles"> <h1>Order</h1><hr /> <div id ='staff'><div style="width:920px; height:autopx; overflow:auto; heightmax:300px"> <table> <tr> <th>pizza number</th> <th>Type</th> <th>Size</th> <th>Topping</th> <th>Cost</th> <th>Information</th> </tr> <?php mysql_connect("localhost", "root", "")or die("cannot connect"); mysql_select_db("deliverpizza")or die("cannot select DB"); $sql="SELECT * FROM `pizzatopping` "; $result= mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $pizza = $row['id']; if(isset($_POST["pizza$pizza"])) { if ($_POST["pizza$pizza"] == $row['id']){ $id = $row['id']; $dis="SELECT * FROM `pizzatopping` where id='$id'"; $result= mysql_query($dis); while($row =mysql_fetch_assoc($result)){ ?> <tr> <td><?php echo $row['id'] ?></td> <td><?php echo $row['type'] ?></td> <td><?php echo $row['size'] ?></td> <td><?php echo $row['topping'] ?></td> <td><?php echo $row['cost'] ?></td> <td><?php echo $row['info'] ?></td> </tr> <?php } } } } ?> </table> </div> </div> </div> </div> <!--end content--> <div id="footer"><span><p>Created By Ryan Williams</p></span></div><!--end footer--> </div><!--end container--> </body> </html>
  5. i have got it working now thanks
  6. Hi, i have been thinking on ways to make an ordering system for my web site. The code bellow shows how i populate the page. i desplay the pizza's from the data base. i want at the end of each line a box thati allows the user to pick howmany pizzas they want. from they when they click order i want it to send all the information of what they want so they can double check it and when they click the final order button it will send to a diffrent order table. <? session_start(); if ($_SESSION['userName']) {} else { header('location:../index.php'); } ?> <!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>Deliver-Pizza Topping</title> <link href="css/pizza-topping.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <img src="images/logo.jpg" alt="logo" /> <a href="log-off.php" id="logg-off" >log off</a> <ul id="nav"> <li><a href="home.php" target="_self">Home</a></li> <span> | </span> <li><a href="Pizza-Topping.php" target="_self">Pizza Topping</a></li> <span> | </span> <li><a href="order.php" target="_self">Order</a></li> <span> | </span> <li><a href="Account.php" target="_self">Account Details</a></li> <span> | </span> </ul> </div> <div id="Featured"> <img src="images/banner1.jpg" alt="banner" name="banner"" ID="banner"></div><!--end Featured--> <div class="featuredimage" id="main"> <div id="content" class="tiles"> <h1>Pizza-Topping</h1><hr /> <p>Please select the pizza you would like bellow</p> <div id ="staff"><div style="width:970px; height:300px; overflow:auto" <left> <table> <tr> <th>Type</th> <th>Size</th> <th>Topping</th> <th>Cost</th> <th>Information</th> <th>Order</th> </tr> <tr> <form name="input" action="order.php" method="post"> <?php mysql_connect("localhost", "root", "")or die("cannot connect"); mysql_select_db("deliverpizza")or die("cannot select DB"); $sql="SELECT * FROM `pizzatopping` "; $result= mysql_query($sql); while($row =mysql_fetch_assoc($result)) { ?> <td><?php echo $row['type'] ?></td> <td><?php echo $row['size'] ?></td> <td><?php echo $row['topping'] ?></td> <td><?php echo $row['cost'] ?></td> <td><?php echo $row['info'] ?></td> <td> <input type:"text" name:"pizza<?php echo $row['id'] ?>" /></td> </tr></left> <?php } ?> <input type="submit" value="Order" /> </table> </div> </div> </div> </div> <!--end content--> <div id="footer"><span><p>Created By Ryan Williams</p></span></div><!--end footer--> </div><!--end container--> </body> </html> Help please
  7. yahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh Thank you all for your help. i will say a very big thank you to PFMaBiSmAd. the bit of code that you gave me work.
  8. Thanks kojote for all your help so far. I have done what you said and i have gone into phpmyadmin and test the sql. when I insert the code into my sql i get all the user names from all the tables Insted of the one i am wanting.
  9. aykay47: i have changed the session to the one you said. Thanks I am now getting a diffrent error: Below is the code that i am using now: <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="deliverpizza"; // Database name $tbl_name="customer, admin, staff"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM customer UNION ALL SELECT * FROM admin UNION ALL SELECT * FROM staff WHERE username='$myusername' and password='$mypassword'"; //$result=mysql_query($sql); //$sql="SELECT * FROM $tbl_name WHERE userName='$myusername' and password='$mypassword'"; $result=mysql_query($sql) or die($sql . "<br />" . mysql_error()); // Mysql_num_row is counting table row $count=mysql_fetch_assoc($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" $_SESSION['myusername'] = $myusername; $_SESSION['mypassword'] = $mypassword; header("location:login_privelage.php"); } else { } ?> and here are the screen shots of the three different tables that i am using to log into the database. I have attached them.
  10. I now get the error: and this is the code: <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="deliverpizza"; // Database name $tbl_name="customer, admin, staff"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM customer UNION ALL SELECT * FROM admin UNION ALL SELECT * FROM staff WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_fetch_assoc($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_privelage.php"); } else { } ?>
  11. Thanks for the help so far, I still seem to be struggling to get this to work (fairly new to PHP), Pikachu2000, could you recommend a more suitable learning resource?
  12. Thanks that work well thanks. thanks for the help
  13. When I log in on my web-site it takes me to a php login-check page This is the error code that I am getting; This is the php code that i am using; <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="deliverpizza"; // Database name $tbl_name="customer, admin, staff"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_privelage.php"); } else { } ?>
  14. I am trying to insert a new user into my database from my php code. This is the error message that I am getting from the webpage: This is the code that I am using: <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("deliverpizza", $con); $sql="INSERT INTO customer(userName, password, privilege, firstName, lastName, address, postCode, order, previousOrder) VALUES ('$_POST[username]','$_POST[password]','$_POST[privilege]','$_POST[firstname]','$_POST[lastname]','$_POST[address]','$_POST[postcode]','$_POST[order]','$_POST[previousOrder]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?>
×
×
  • 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.