Jump to content

psychowolvesbane

Members
  • Posts

    204
  • Joined

  • Last visited

    Never

Everything posted by psychowolvesbane

  1. No it doesn't like the line if(document.AddProduct.ItemType.options[document.AddProduct.ItemType.selectedIndex].value='0'), I changed the default value of the selection to "0" and it displays the error message even when an Item Type has been selected. Then changes the selected option back to the default again. if(document.AddProduct.ItemType.value='0') { document.getElementById('mySpan3').innerHTML='! Please Choose an ItemType!'; Errors++; alert("3"); } else { document.getElementById('mySpan3').innerHTML=''; } [code] Plus I'm baffled by another problem with my Price1 val. It validates it fine but for some reason it just doesn't want to activate the mySpan4 message even though it's inside the accessed selection statement. I get the alerts correctly when I do something wrong but no message in my span. Yet it works fine in my unaltered Price2 validation. [code] if(document.AddProduct.Price1.value='0') { document.getElementById('mySpan4').innerHTML='! Please Enter the Price!'; Errors++; alert("4A"); } else if(IsNumeric(document.AddProduct.Price1.value) == false) { document.getElementById('mySpan4').innerHTML='! Please Enter the Price!'; Errors++; alert("4B"); } else { document.getElementById('mySpan4').innerHTML='blah blah'; alert("4C"); } if((document.AddProduct.Price2.value+'').length<1) { document.getElementById('mySpan4').innerHTML='! Please Enter the Price!'; Errors++; alert("4D"); } else { document.getElementById('mySpan4').innerHTML=''; alert("4E"); } [/code][/code]
  2. Okay I managed to get it working but I still have a few kinks to work out such as numeric and select list validation, which I'm not sure how to achieve. I have this as my current Select list validation but it doesn't want to work. if(document.AddProduct.ItemType.value='') { document.getElementById('mySpan3').innerHTML='! Please Choose an ItemType!'; Errors++; alert(3); } else { document.getElementById('mySpan3').innerHTML=''; } Then i'm not sure about how to go about doing numeric validation for my Price and NUSPrice fields as i can still allow characters to be submitted.
  3. Can anyone help me see where I'm going wrong? I'm not that competent with Javascript yet but i'm trying.
  4. Nope that wasn't it, I noticed thanks to the slightly better colour coded formatting from this site that the while loop from the Category search wasn't closing properly, so I just copied the Criterion while loop and made the necessary changes and it now works! I noticed that the closing bracket for the while loop was blue instead of green, but on Dream Weaver it doesn't have a colour formatting for brackets.
  5. I have a search page which takes in 2 types of searches, Categories (list of product categories) and Criteria (input from a search bar), at the moment all the page does is show a blank screen so I must be missing an important php/html character somewhere, but i'm tried searching for it using Dreamweaver CS3 and it's useful colour coded formatting but I still can't see anything wrong with it. <?php $Category = $_GET['Category']; $Criterion = $_GET['Criterion']; ?> <html> <head> <title>Clothing Line</title> <link href="admin/stylesheetCL.css" rel="stylesheet"> <?php require('admin/jscript.inc') ?> </head> <body> <?php //require('admin/header.inc'); include "admin/connect_details.php"; require('menu.inc'); //require('search_results.inc');?> <div style="position:absolute; top:5px; left:200px; width:550px"> <?php echo $Category." is Category<br>"; echo $Criterion." is Criterion<br>"; If ($Category != "") { $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT ClothingCode,Description,Price FROM Clothing WHERE ItemType = '$Category' ORDER BY ClothingCode"; $rs = mysql_query($sql, $conn) or die('Problem with query: ' . $sql . '<br />' . mysql_error()); $Results1 = mysql_num_rows($rs); echo"<span class='errmsg'>There were $Results1 search results for $Category</span>"; echo $Results1." is Category results"; echo"<span class='head3'>Search results for category: $Category</span><br><br>"; ?> <table border="0" cellpadding="3"><tr> <th>Clothing Code</th> <th>Description</th> <th>Price</th></tr> <?php while($row = mysql_fetch_array($rs)) { $ClothingCode = $row['ClothingCode']; $Description = $row['Description']; $Price = number_format($row['Price'],2); echo "<tr style=\"color:seagreen; line-height:8pt\" onMouseOver=\"this.style.backgroundColor='lightgreen';this.style.color='darkgreen'; this.style.cursor='hand'\"onMouseOut=\"this.style.backgroundColor='white';this.style.color='seagreen'\" onClick=\"location.href='details.php?&ClothingCode=$row['ClothingCode']\".\"&Category=$Category'\"> <td>$ClothingCode</td><td>$Description</td><td align='right'>£$Price</td></tr>"; } mysql_close($conn); ?> </table> <?php } elseif ($Criterion != "") { $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT ClothingCode,Description,Price FROM Clothing WHERE"; $sql = $sql . " ClothingCode LIKE '%" . $Criterion . "%'"; $sql = $sql . " OR Description LIKE '%" . $Criterion . "%'"; $sql = $sql . " OR ItemType LIKE '%" . $Criterion . "%'"; $sql = $sql . " OR AvailableSizes LIKE '%" . $Criterion . "%'"; $sql = $sql . " OR AvailableColours LIKE '%" . $Criterion . "%'"; $sql = $sql . " ORDER BY ClothingCode"; $rs = mysql_query($sql,$conn) or die('Problem with query: ' . $sql . '<br />' . mysql_error()); $Results2 = mysql_num_rows($rs); echo $Results2." is Criterion results"; echo"<span class='errmsg'>There were $Results2 search results for $Criterion</span>"; echo"<span class='head3'>Search results for Clothing Code: $Criterion</span><br><br>"; ?> <table border="0" cellpadding="3"><tr> <th>Clothing Code</th><th>Description</th><th>Price</th></tr> <?php while($row = mysql_fetch_array($rs)) { $ClothingCode = $row['ClothingCode']; $Description = $row['Description']; $Price = $row['Price']; echo "<tr style=\"color:seagreen; line-height:8pt\"onMouseOver=\"this.style.backgroundColor='lightgreen'; this.style.color='darkgreen';this.style.cursor='hand'\"onMouseOut=\"this.style.backgroundColor='white'; this.style.color='seagreen'\"onClick=\"location.href='details.php?ClothingCode=$ClothingCode'\". \"&Criterion=$Criterion'\"> <td>$ClothingCode</td> <td>$Description</td> <td align=\"right\">£$Price</td> </tr>"; } mysql_close($conn); ?> </table> <?php } ?> </div> </body> </html>
  6. I have this form with validation that is newly added, atm it does not activate the Validate() function from the onsubmit feature of the form, and the php validation kicks in after submitting. I can't see what is stopping it from working, and Firebug is not picking up any errors when activated. If it was working I would be getting the alter pop-ups. <?php include "connect_details.php"; session_start(); $CBSizes = array("XS","Small", "Medium", "Large", "XL", "XXL", "3XL"); $Submit = $_POST['SubmitB']; $Errors=0; $Valid_ClothingCode = true; $Valid_Description = true; $Valid_Price = true; $Valid_NUSPrice = true; $Valid_ItemType = true; $Valid_ProductImage = true; $Valid_ASizes = true; $Valid_AColours = true; if($Submit =="Submit") { $ClothingCode = $_POST['ClothingCode']; $Description = $_POST['Description']; $ItemType = $_POST['ItemType']; $Price1 = $_POST['Price1']; $Price2 = $_POST['Price2']; $NUSPrice1 = $_POST['NUSPrice1']; $NUSPrice2 = $_POST['NUSPrice2']; $ProductImage = $_FILES['ProductImage']['name']; $Max_Size = 102400; $dirupload = "../images/products/"; $Imagetype = $_FILES['ProductImage']['type']; $Imagesize = $_FILES['ProductImage']['size']; $ProductImage = $_FILES['ProductImage']['name']; $image_temp = $_FILES['ProductImage']['tmp_name']; list($width, $height) = getimagesize($image_temp); $dirupload = "../images/products/"; $AColours = $_POST['Colours']; $ASizes = $_POST['Sizes']; //ClothingCode Validation if(empty($ClothingCode)) { $Message_ClothingCode = "! Please Enter the Clothing Code! (PHP)"; $Errors++; $Valid_ClothingCode = false; } //Description Validation if(empty($Description)) { $Message_Description = "! Please Enter the Description! (PHP)"; $Errors++; $Valid_Description = false; } //Item Type Validation if(empty($ItemType)) { $Message_ItemType = "! Please Select an Item Type! (PHP)"; $Valid_ItemType = false; $Errors++; } //Price Validation if(empty($Price1)) { $Message_Price = "! Please Enter the Price! (PHP)"; $Errors++; $Valid_Price = false; } elseif((is_numeric($Price1) == false) || (is_numeric($Price2) == false)) { $Message_Price = "! That is not a valid Price! (PHP)"; $Errors++; $Valid_Price = false; } else { $Price = $Price1.".".$Price2; $Valid_Price = true; } //NUS Price Validation if(empty($NUSPrice1)) { $Message_NUSPrice = "! Please Enter the NUS Price! (PHP)"; $Errors++; $Valid_NUSPrice = false; } elseif((is_numeric($NUSPrice1) == false) || (is_numeric($NUSPrice2) == false)) { $Message_NUSPrice = "! That is not a valid NUS Price! (PHP)"; $Errors++; $Valid_NUSPrice = false; } else { $NUSPrice = $NUSPrice1.".".$NUSPrice2; $Valid_NUSPrice = true; } //Product Image Validation if($_SESSION['ProductImage'] == "") { if ((($Imagetype == "image/jpg") || ($Imagetype == "image/jpeg") || ($Imagetype == "image/jpe")) && ($Imagesize < $Max_Size) && ($width <= 250) && ($height <=300)) { if (file_exists($dirupload . $_FILES['ProductImage']['name']."jpg")) { $Message_ProductImage = "! That file already exists! (PHP)"; $Valid_ProductImage = false; $Errors++; } else { $_SESSION['ProductImage']=$ProductImage; $Valid_ProductImage = true; } } else { $Valid_ProductImage = false; $Errors++; $Message_ProductImage = "! Please Select a .jpg image file that is no more than 300x250 pixels in size, and is less than 100kb! (PHP)"; } } else { $image_temp= $_SESSION['ProductImage']; $Valid_ProductImage =true; } //Available Sizes Section if(count($ASizes) > 0) { foreach($ASizes AS $Sizes) { $Valid_ASizes=True; $SizeA[$Sizes]= true; $AvailableSizes.=$Sizes."?"; } } else { $Valid_ASizes=False; $Errors++; $Message_ASizes = "! Please Choose any Relevant Sizes! (PHP)"; } //Available Colours Section if(count($AColours) > 0) { foreach($AColours AS $Colours) { $Valid_AColours=True; $ColourA[$Colours]= true; $AvailableColours.=$Colours."?"; } } else { $Valid_AColours=False; $Errors++; $Message_AColours = "! Please Choose any Relevant Colours! (PHP)"; } // Upload Section if($Errors==10) { $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sqlNew = "INSERT INTO Clothing (ClothingCode,Description,ItemType,Price,NUSPrice,AvailableSizes,AvailableColours) VALUES('$ClothingCode','$Description','$ItemType','$Price','$NUSPrice','$AvailableSizes','$AvailableColours')"; $rsNew = mysql_query($sqlNew,$conn)or die('Problem with query: ' . $sqlNew . '<br />' . mysql_error()); if(mysql_affected_rows($conn) == 1) { $move_image = move_uploaded_file($image_temp, $dirupload.$ClothingCode.".jpg"); $_SESSION['NewProduct'] = $ClothingCode; $_SESSION['NewAction'] = "Added"; } elseif(mysql_affected_rows($conn) == 0) { $_SESSION['NewAction'] = "NotAdded"; } mysql_close($conn); $Cont= true; } } ?> <html> <head> <title>Clothing Line</title> <link href="stylesheetCL.css" rel="stylesheet"> <?php require('jscript.inc'); if($Cont == true) { unset($_SESSION['ProductImage']); ?> <meta HTTP-EQUIV="REFRESH" content="0; url=display_products.php?Action=Edit"> <?php } ?> <script language='JavaScript' type='text/JavaScript'> <!-- function Validate(f){ return (ValidateValues(f)==0 ? true : false ); } function ValidateValues(f) { var Errors = 0 if((document.AddProduct.ClothingCode.value+'').length<1) { document.mySpan1.innerHTML='! Please Enter a Clothing Code!'; Errors++ alert(1); } else { document.mySpan1.innerHTML=''; } if((document.AddProduct.Description.value+'').length<1) { document.mySpan2.innerHTML='! Please Enter a Description!'; Errors++ alert(2); } else { document.mySpan2.innerHTML=''; } if(document.AddProduct.ItemType.value="0") { document.mySpan3.innerHTML='! Please Choose an ItemType!'; Errors++ alert(3); } else { document.mySpan3.innerHTML=''; } if((document.AddProduct.Price1.value+'').length<1) { document.mySpan4.innerHTML='! Please Enter the Price!'; Errors++ alert(4); } else { document.mySpan4.innerHTML=''; } if((document.AddProduct.Price2.value+'').length<1) { document.mySpan4.innerHTML='! Please Enter the Price!'; Errors++ alert(4); } else { document.mySpan4.innerHTML=''; } if((document.AddProduct.NUSPrice1.value+'').length<1) { document.mySpan5.innerHTML='! Please Enter the NUS Price!'; Errors++ alert(5); } else { document.mySpan5.innerHTML=''; } if((document.AddProduct.NUSPrice2.value+'').length<1) { document.mySpan5.innerHTML='! Please Enter the NUS Price!'; Errors++ alert(5); } else { document.mySpan5.innerHTML=''; } if((document.AddProduct.ProductImage.value+'').length<1) { document.mySpan6.innerHTML='! Please upload a Product Image!'; Errors++ alert(6); } else { document.mySpan6.innerHTML=''; } Sizes = document.AddProduct.Sizes.length checkchar = "" for (i = 0; i < boxes; i++) { if (document.AddProduct.Sizes[i].checked) { checkchar = checkchar + document.AddProduct.Sizes[i].value + " " } } if(checkchar=="") { document.mySpan7.innerHTML='! Please Choose any Relevant Sizes!'; Errors++ alert(7); } else { document.mySpan7.innerHTML=''; } Sizes = document.AddProduct.Colours.length checkchar2 = "" for (i = 0; i < boxes; i++) { if (document.AddProduct.Colours[i].checked) { checkchar2 = checkchar2 + document.AddProduct.Colours[i].value + " " } } if(checkchar2=="") { document.mySpan8.innerHTML='! Please Choose any Relevant Colours!'; Errors++ alert(; } else { document.mySpan8.innerHTML=''; } return Errors; } //--> </script> </head> <body> <?php //require('header.inc') ?> <?php require('menu.inc') ?> <div style="position:absolute; top:5px; left:200px; width:550px"> <span class="head1">New Product Form</span><br><br> <form method="post" enctype="multipart/form-data" name="AddProduct" action="add_product_form.php" onSubmit="return Validate(this);"/> <span id="mySpan1" class="errmsg"><?php echo $Message_ClothingCode?></span><br> <span class="head4">Clothing Code:</span><br> <input type="text" MAXLENGTH="6" name="ClothingCode" value ="<?php echo $ClothingCode?>"/><br><br> <span id="mySpan2" class="errmsg"><?php echo $Message_Description?></span><br> <span class="head4">Description:</span><br> <input type="text" MAXLENGTH="50" name="Description" value ="<?php echo $Description?>"/><br><br> <span id="mySpan3" class="errmsg"><?php echo $Message_ItemType?></span><br> <span class="head4">Item Type:</span><br> <select name="ItemType"/> <option value="">Please Select an Item Type</option> <?php $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType"; $rs = mysql_query($sql, $conn) or die(mysql_error()); while($row = mysql_fetch_array($rs)) { $Type = $row['ItemType']; echo"<option value='$Type'"; if($ItemType == $Type) {echo"Selected";} echo">$Type</option>"; } mysql_close($conn); ?> </select><br><br> <span id="mySpan4" class="errmsg"><?php echo $Message_Price?></span><br> <span class="head4">Price:</span><br> <input type="int" size="1" MAXLENGTH="3" name="Price1" value="<?php echo $Price1?>"/>.<input type="int" MAXLENGTH="2" size="1" name="Price2" value="<?php echo $Price2?>"/><br><br> <span id="mySpan5" class="errmsg"><?php echo $Message_NUSPrice?></span><br> <span class="head4">NUS Price:</span><br> <input type="int" size="1" MAXLENGTH="3" name="NUSPrice1" value="<?php echo $NUSPrice1?>"/>.<input type="int" MAXLENGTH="2" size="1" name="NUSPrice2" value="<?php echo $NUSPrice2?>"/><br><br> <span id="mySpan6" class="errmsg"><?php echo $Message_ProductImage?></span><br> <span class="head4">Product Image: (Must be .jpg image type, 300x250 pixels in dimensions and less than 50Kb in size)</span><br> <input type="file" name="ProductImage"/><br><br> <span id="mySpan7" class="errmsg"><?php echo $Message_ASizes ?></span><br> <span class="head4">Available Sizes:</span><br> <table id="Sizes"><tr> <?php $X=0; while($X!=7) { $Size = $CBSizes[$X]; echo"<td>$Size:</td>"; echo"<td><input type='checkbox' name='Sizes[]' value='$Size'"; if($SizeA[$Size]==true){echo"Checked";}?>></td></tr><tr> <?php $X++; } ?> </tr></table><br> <span id="mySpan8" class="errmsg"><?php echo $Message_AColours ?></span><br> <span class="head4">Available Colours: </span> <table><tr> <?php $conn = mysql_connect($Host,$Username,$Password); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT AvailableColours FROM Colours ORDER BY AvailableColours"; $rs = mysql_query($sql, $conn) or die(mysql_error()); $NumberOfColours = mysql_num_rows($rs); $counter = 0; $X = 0; if ($result || (mysql_num_rows($rs) > 0)) { while ($row = mysql_fetch_assoc($rs)) { $AvailableColour = $row['AvailableColours']; if($counter%9==0&&$counter!=0) echo "</tr><tr>"; echo "<td><img src='/images/colours/$AvailableColour.gif' title='$AvailableColour'/><br />"; echo "<td><input type='checkbox' name='Colours[]' value='$AvailableColour'"; if($ColourA[$AvailableColour]==true){echo"Checked";} echo "></td>"; $X++; ++$counter; } } ?> </tr></table> <?php mysql_close($conn); ?> <br><br> <input type="submit" name="SubmitB" value="Submit"> </form><br> <br><br> <a href="admin.php">Back to the Admin Menu</a> </div> </body> </html>
  7. So would it be unset($_SESSION['Value']); ?
  8. I have a website that's using more than one session running on a single page at any one time, but I don't know how to destroy a specific session and not all of them, which I don't want. Can anyone show me an example of destroying 1 on its own without effecting any others?
  9. Try: <?php include "cart/index.php"; ?>
  10. That was it! Thank you, now I just need to add all the SESSION stuff to the other pages so it won't need to re-login everytime.
  11. The username and password still are not being accepted :-\ <?php session_Start(); include "admin/connect_details.php"; $LoginB = $_POST['LoginB']; $UserLogin = $_POST['Username']; $PasswordLogin = $_POST['Password']; echo "Username = $UserLogin<br>"; echo "Password = $PasswordLogin<br>"; if($_SESSION['AdminLogin']==true) { $_SESSION['AdminLogin']=true; $ValidLogin = true; } else { if(empty($UserLogin)) { $Valid_Username = false; $Errors++; $MessageUser = "Please enter a Username"; } if(empty($PasswordLogin)) { $Valid_Password = false; $Errors++; $MessagePassword = "Please enter a Password"; } if($Errors==0) { $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); //$sql = "SELECT Username,Password FROM UserAccount WHERE Username='$UserLogin' && Password='$PasswordLogin'"; $sql = "SELECT `Username`, `Password` FROM `UserAccount` WHERE `Username` = 'UserLogin' AND `Password` = '$PasswordLogin'"; $rs = mysql_query($sql,$conn) or die('Problem with query: ' . $sql . '<br />' . mysql_error()); if(mysql_num_rows==0) { $Errors++; $MessageForm = "Invalid UserName/Password!"; $ValidLogin = false; } else { $_SESSION['AdminLogin']=true; $ValidLogin = true; } mysql_close($conn); } } ?> <html> <head> <title>Clothing Line</title> <link href="admin/stylesheetCL.css" rel="stylesheet"> <?php require('admin/jscript.inc') ?> <?php if($ValidLogin==true && $_SESSION['AdminLogin']==true) { ?> <meta HTTP-EQUIV="REFRESH" content="0; url=admin/admin.php"> <?php } ?> </head> <body> <?php //require('admin/header.inc') ?> <?php require('menu.inc') ?> <div style="position:absolute; top:5px; left:200px; width:550px"> <?php if($ValidLogin==false) { echo "<span class='errmsg'>! $MessageForm</span><br><br>"; } ?> <form method="post" action='login_form.php'/> <?php if($LoginB != "Submit") { ?> Username: <input type="text" name="Username" value=""/> <br> <br> Password: <input type="password" name="Password" value=""/> <br> <br> <?php } elseif($LoginB == "Submit") { if($Valid_Username == false) { ?> <span class="errmsg">! $MessageUser</span><br> <?php } ?> Username: <input type="text" name="Username" value="<?php echo $UserLogin?>"/> <br> <br> <?php if($Valid_Password == false) { ?> <span class="errmsg">! $MessagePassword</span><br> <?php } ?> Password: <input type="password" name="Password" value="<?php echo $PasswordLogin?>"/> <br> <br> <?php } ?> <input type="submit" class="buttonS" name="LoginB" value="Go" onMouseOver="OverMouse(this)"; onMouseOut="OutMouse(this)"/> </form> </div> </body> </html> [code] [/code]
  12. However it is going to my "Invalid Usernamer/Password" message when I enter the correct details. Here's my current code <?php session_Start(); include "admin/connect_details.php"; $LoginB = $_POST['LoginB']; $UserLogin = $_POST['Username']; $PasswordLogin = $_POST['Password']; if($_SESSION['AdminLogin']==true) { $_SESSION['AdminLogin']=true; $ValidLogin = true; } else { if(empty($UserLogin)) { $Valid_Username = false; $Errors++; $MessageUser = "Please enter a Username"; } if(empty($PasswordLogin)) { $Valid_Password = false; $Errors++; $MessagePassword = "Please enter a Password"; } if($Errors==0) { $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT UserName,Password FROM UserAccount WHERE Username='$UserLogin' AND Password='$PasswordLogin'"; $rs = mysql_query($sql,$conn) or die('Problem with query: ' . $sql . '<br />' . mysql_error()); if(mysql_affected_rows==0) { $Errors++; $MessageForm = "Invalid UserName/Password!"; $ValidLogin = false; } else { $_SESSION['AdminLogin']=true; $ValidLogin = true; } mysql_close($conn); } } ?> <html> <head> <title>Clothing Line</title> <link href="admin/stylesheetCL.css" rel="stylesheet"> <?php require('admin/jscript.inc') ?> <?php if($ValidLogin==true && $_SESSION['AdminLogin']==true) { ?> <meta HTTP-EQUIV="REFRESH" content="0; url=admin/admin.php"> <?php } ?> </head> <body> <?php require('admin/header.inc') ?> <?php require('menu.inc') ?> <div style="position:absolute; top:5px; left:200px; width:550px"> <?php if($ValidLogin==false) { echo "<span class='errmsg'>! $MessageForm</span><br><br>"; } ?> <form method="post" action='login_form.php'/> <?php if($LoginB != "Submit") { ?> Username: <input type="text" name="Username" value=""/> <br> <br> Password: <input type="password" name="Password" value=""/> <br> <br> <?php } elseif($LoginB == "Submit") { if($Valid_Username == false) { ?> <span class="errmsg">! $MessageUser</span><br> <?php } ?> Username: <input type="text" name="Username" value="<?php echo $UserLogin?>"/> <br> <br> <?php if($Valid_Password == false) { ?> <span class="errmsg">! $MessagePassword</span><br> <?php } ?> Password: <input type="password" name="Password" value="<?php echo $PasswordLogin?>"/> <br> <br> <?php } ?> <input type="submit" class="buttonS" name="LoginB" value="Go" onMouseOver="OverMouse(this)"; onMouseOut="OutMouse(this)"/> </form> </div> </body> </html>
  13. I changed the sql to $sql = "SELECT UserName,Password FROM UserAccount WHERE Username='$UserLogin' AND Password='$PasswordLogin'";
  14. Okay now i'm getting a syntax error for the sql, most likely because of the WHERE part, I didn't know exactly how to specify more than 1 criteria so I made an educated guess.
  15. I have a form for logging in to an Admin folder which should restrict access to the pages there (I will also have a htaccess file stopping access in the address bar but no password file) but the form comes up blank on the screen so it must be some vital thing I have missed on the page like a if statement { or something, yet I have tried searching and can't find anything so I need another pair of eyes to help me find the bugger. <?php session_Start(); include "admin/connect_details.php"; $LoginB = $_POST['LoginB']; $UserLogin = $_POST['Username']; $PasswordLogin = $_POST'['Password']; if($_SESSION['AdminLogin']==true) { $_SESSION['AdminLogin']=true; $ValidLogin = true; } else { if(empty($UserLogin)) { $Valid_Username = false; $Errors++; $MessageUser = "Please enter a Username"; } if(empty($PasswordLogin)) { $Valid_Password = false; $Errors++; $MessagePassword = "Please enter a Password"; } if($Errors==0) { $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT UserName,Password FROM Clothing WHERE Username='$UserLogin',Password='$PasswordLogin'"; $rs = mysql_query($sql,$conn) or die('Problem with query: ' . $sql . '<br />' . mysql_error()); if(mysql_affected_rows==0) { $Errors++; $MessageForm = "Invalid UserName/Password!"; $ValidLogin = false; } else { $_SESSION['AdminLogin']=true; $ValidLogin = true; } mysql_close($conn); } } ?> <html> <head> <title>Clothing Line</title> <link href="admin/stylesheetCL.css" rel="stylesheet"> <?php require('admin/jscript.inc') ?> <?php if($ValidLogin==true && $_SESSION['AdminLogin']==true) { ?> <meta HTTP-EQUIV="REFRESH" content="0; url=admin/admin.php"> <?php } ?> </head> <body> <?php require('admin/header.inc') ?> <?php require('menu.inc') ?> <div style="position:absolute; top:5px; left:200px; width:550px"> <?php if($ValidLogin==false) { echo "<span class='errmsg'>! $MessageForm</span><br><br>"; } ?> <form method="post" action='login_form.php'/> <?php if($LoginB != "Submit") { ?> Username: <input type="text" name="Username" value=""/> <br> <br> Password: <input type="password" name="Password" value=""/> <br> <br> <?php } elseif($LoginB == "Submit") { if($Valid_Username == false) { ?> <span class="errmsg">! $MessageUser</span><br> <?php } ?> Username: <input type="text" name="Username" value="<?php echo $UserLogin?>"/> <br> <br> <?php if($Valid_Password == false) { ?> <span class="errmsg">! $MessagePassword</span><br> <?php } ?> Password: <input type="password" name="Password" value="<?php echo $PasswordLogin?>"/> <br> <br> <?php } ?> <input type="submit" class="buttonS" name="LoginB" value="Go" onMouseOver="OverMouse(this)"; onMouseOut="OutMouse(this)"/> </form> </div> </body> </html>
  16. Thanks Thorpe, I knew it had to be something obvious but it seems to have worked before even with the quotes because the $Added=true and $NotExec= false were activated as usual when the sql ran perfectly, strange.
  17. I have a form with an image upload feature, I want it so the move_uploaded_files() script occurs after the INSERT SQL query has successfully been completed, however whenever I try moving the line $move_image into an if statement to try and catch it out it doesn't seem to operate yet works perfectly outside of them unrestricted. Here's my code for that part of the form. Also, take it that the variables and their contents are correct upon entry. ... $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sqlNew = "INSERT INTO Clothing (ClothingCode,Description,ItemType,Price,NUSPrice,AvailableSizes,AvailableColours) VALUES('$ClothingCode','$Description','$ItemType','$Price','$NUSPrice','$AvailableSizes','$AvailableColours')"; $rsNew = mysql_query($sqlNew,$conn)or die('Problem with query: ' . $sqlNew . '<br />' . mysql_error()); if(mysql_affected_rows($conn) == "1") { $move_image = move_uploaded_file($image_temp, $dirupload.$ClothingCode.".jpg"); // <--- This is the culprit $Added = true; $NotExec = false; } elseif(mysql_affected_rows($conn) =="0") { $Added = false; $NotExec = true; ?> <div style="position:Relative; top:250px; left:200px; width:550px"> <span class="errmsg">Could not be added, <?php echo "$ClothingCode";?> may already exist!</span> </div> <?php } mysql_close($conn); ... Can anyone see what I'm doing wrong?
  18. Have you tried ordering the records into descending order in your sql selection?
  19. Are you sure you want the semi colons on the if statements as well??? ... if ($_POST['name'] = ($results['name'])); //<--Here { print "Name exists"; } elseif ($_POST['email'] = ($results['email'])); //<-- and Here { print "Email exists"; exit(); } else { ... Try removing them.
  20. I have a form with a an image upload, I want it so the move_uploaded_files() script occurs after the SQL query has successfully been completed, however the way I have tried to do this does not work, but works fine if I don't restrict it to a successful query, here's my code for that part of the form. Also take it that the variables and their contents are correct. ... $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sqlNew = "INSERT INTO Clothing (ClothingCode,Description,ItemType,Price,NUSPrice,AvailableSizes,AvailableColours) VALUES('$ClothingCode','$Description','$ItemType','$Price','$NUSPrice','$AvailableSizes','$AvailableColours')"; $rsNew = mysql_query($sqlNew,$conn)or die('Problem with query: ' . $sqlNew . '<br />' . mysql_error()); if(mysql_affected_rows($conn) == "1") { $move_image = move_uploaded_file($image_temp, $dirupload.$ClothingCode.".jpg"); // <--- This is the culprit $Added = true; $NotExec = false; } elseif(mysql_affected_rows($conn) =="0") { $Added = false; $NotExec = true; ?> <div style="position:Relative; top:250px; left:200px; width:550px"> <span class="errmsg">Could not be added, <?php echo "$ClothingCode";?> may already exist!</span> </div> <?php } mysql_close($conn); ... Can anyone see what I'm doing wrong?
  21. Thank you! That has actually solved both .jpeg and .gif file problems, even if I upload an animation it still counts as the one image, animations usually stick to a certain dimension even if it's only 1 image that is that big and the rest smaller.
  22. P.S. I meant to say why .jpeg file dimensions aren't being restricted.
  23. Okay but it still doesn't exaplin why .jpeg files aren't being restricted. I'm made a few modifications that I thought would help from other working code (I presumed they were working) found on the forum: <?php include "connect_details.php"; $CBSizes = array("XS","Small", "Medium", "Large", "XL", "XXL", "3XL"); $Submit = $_POST['SubmitB']; $errors=0; if($_POST['SubmitB'] =="Submit") { $ClothingCode = $_POST['ClothingCode']; $Description = $_POST['Description']; $ItemType = $_POST['ItemType']; $Price1 = $_POST['Price1']; $Price2 = $_POST['Price2']; $NUSPrice1 = $_POST['NUSPrice1']; $NUSPrice2 = $_POST['NUSPrice2']; $ProductImage = $_FILES['ProductImage']['name']; $Max_Size = 51200; $Imagetype = $_FILES['ProductImage']['type']; $Imagesize = $_FILES['ProductImage']['size']; $image_temp = $_Files['ProductImage']['tmp_name']; list($width, $height) = getimagesize($image_temp); echo $Imagesize; echo"<br>"; echo $Imagetype; echo"<br>"; echo $width; echo"<br>"; echo $height; echo"<br>"; $dirupload = "../images/products/"; $NotExec = true; $AColours = $_POST['Colours']; $ASizes = $_POST['Sizes']; //ClothingCode Validation if(empty($ClothingCode)) { ?> <div style="position:absolute; top:10px; left:200px; width:550px"> <span class="errmsg">Please Enter the Clothing Code</span> </div> <?php $errors++; $Valid_ClothingCode = false; } //Description Validation if(empty($Description)) { ?> <div style="position:absolute; top:25px; left:200px; width:550px"> <span class="errmsg">Please Enter the Description</span> </div> <?php $errors++; $Valid_Description = false; } //Item Type Validation if(empty($ItemType)) { ?> <div style="position:absolute; top:40px; left:200px; width:550px"> <span class="errmsg">Please Select an Item Type!</span> </div> <?php $Valid_ItemType = false; $errors++; } //Price Validation if((empty($Price1)) || empty($Price2)) { ?> <div style="position:absolute; top:55px; left:200px; width:550px"> <span class="errmsg">Please Enter the Price</span> </div> <?php $errors++; $Valid_Price = false; } elseif((is_numeric($Price1) == false) || (is_numeric($Price2) == false)) { ?> <div style="position:absolute; top:55px; left:200px; width:550px"> <span class="errmsg">That is not a valid Price!</span> </div> <?php $errors++; $Valid_Price = false; } else { $Price = $Price1.".".$Price2; $Valid_Price = true; } //NUS Price Validation if((empty($NUSPrice1)) || empty($NUSPrice2)) { ?> <div style="position:absolute; top:70px; left:200px; width:550px"> <span class="errmsg">Please Enter the NUS Price</span> </div> <?php $errors++; $Valid_NUSPrice = false; } elseif((is_numeric($NUSPrice1) == false) || (is_numeric($NUSPrice2) == false)) { ?> <div style="position:absolute; top:70px; left:200px; width:550px"> <span class="errmsg">That is not a valid NUS Price!</span> </div> <?php $errors++; $Valid_NUSPrice = false; } else { $NUSPrice = $NUSPrice1.".".$NUSPrice2; $Valid_NUSPrice = true; } //Product Image Validation if ((($Imagetype == "image/jpg") || ($Imagetype == "image/jpeg") || ($Imagetype == "image/jpe")) && ($Imagesize < $Max_Size) && ($width <= 300) && ($height <=250)) { if (file_exists($dirupload . $_FILES['ProductImage']['name']."jpg")) { ?> <div style="position:absolute; top:85px; left:200px; width:550px"> <span class="errmsg">That file already exists!</span> </div> <?php $Valid_ProductImage = false; $errors++; } } else { $Valid_ColourImage = false; $errors++; ?> <div style="position:absolute; top:85px; left:200px; width:550px"> <span class="errmsg">Please Select a .jpg image file that is no more than 300x250 pixels in size, and is less than 50kb</span> </div> <?php } //Available Sizes Section if(count($ASizes) > 0) { foreach($ASizes AS $Sizes) { $Valid_ASizes=True; $SizeA[$Sizes]= true; $AvailableSizes .=$Sizes."?"; echo"<br>"; } } else { $Valid_ASizes=False; $errors++; ?> <div style="position:absolute; top:100px; left:200px; width:550px"> <span class="errmsg">Please select a size!</span> </div> <?php } //Available Colours Section if(count($AColours) > 0) { foreach($AColours AS $Colours) { $Valid_AColours=True; $ColourA[$Colours]= true; $AvailableColours .=$Colours."?"; echo"<br>"; } } else { $Valid_AColours=False; $errors++; ?> <div style="position:absolute; top:115px; left:200px; width:550px"> <span class="errmsg">Please select a Colour!</span> </div> <?php } // Upload Section if($errors==0) { } } ?> <html> <head> <title>Clothing Line</title> <link href="stylesheetCL.css" rel="stylesheet"> <?php require('jscript.inc') ?> </head> </head> <body> <?php require('menu.inc') ?> <div style="position:absolute; top:75px; left:200px; width:550px"> <form method="post" enctype="multipart/form-data" action='add_product_form.php'/> <?php if($_POST['SubmitB'] != "Submit") { ?> <br> Clothing Code: <br> <input type="text" MAXLENGTH="6" name="ClothingCode"/> <br> <br> Description: <br> <input type="text" MAXLENGTH="30" name="Description"/> <br> <br> Item Type: <br> <select name="ItemType"/> <option value="">Please Select an Item Type</option> <?php //Establish a connection to the Database $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); //Select the MySQL database $db = mysql_select_db($Dbname, $conn); $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType"; $rs = mysql_query($sql, $conn) or die(mysql_error()); while($row = mysql_fetch_array($rs)) { echo"<option value='{$row['ItemType']}'>{$row['ItemType']}</option>"; } mysql_close($conn); ?> </select> <br> <br> Price: <br> <input type="int" size="1" MAXLENGTH="3" name="Price1"/>.<input type="int" MAXLENGTH="2" size="1" name="Price2"/> <br> <br> NUS Price: <br> <input type="int" size="1" MAXLENGTH="3" name="NUSPrice1"/>.<input type="int" MAXLENGTH="2" size="1" name="NUSPrice2"/> <br> <br> Product Image: (Must be .jpg image type, 300x250 pixels in dimensions and less than 50Kb in size) <br> <input type="file" name="ProductImage"> <br> <br> Available Sizes: <br> <table id="Sizes"> <tr> <?php $X=0; while($X!=7) { $Size = $CBSizes[$X]; ?> <td><?php echo $Size?>:</td> <td><input type="checkbox" name="Sizes[]" value="<?php echo $Size?>"></td> </tr> <tr> <?php $X++; } ?> </tr> </table> <br> Available Colours: <table><tr> <?php //Establish a connection to the Database $conn = mysql_connect($Host,$Username,$Password); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT AvailableColours FROM Colours ORDER BY AvailableColours"; $rs = mysql_query($sql, $conn) or die(mysql_error()); $NumberOfColours = mysql_num_rows($rs); $counter = 0; if ($result || (mysql_num_rows($rs) > 0)) { while ($row = mysql_fetch_assoc($rs)) { if($counter%9==0&&$counter!=0) echo "</tr><tr>"; echo "<td><img src='/images/colours/{$row['AvailableColours']}.gif' title='{$row['AvailableColours']}'/><br />"; echo "<td><input type='checkbox' name='Colours[]' value='{$row['AvailableColours']}'></td>"; echo "</td>"; ++$counter; } } echo "</tr></table>"; mysql_close($conn); ?> <br> <br> <?php } elseif($_POST['SubmitB'] == "Submit") { ?> <br> Clothing Code: <br> <input type="text" MAXLENGTH="6" name="ClothingCode" value ="<?php echo $_POST['ClothingCode']; ?>"/> <br> <br> Description: <br> <input type="text" MAXLENGTH="30" name="Description" value ="<?php echo $_POST['Description']?>"/> <br> <br> Item Type: <br> <select name="ItemType"/> <option value="">Please Select an Item Type</option> <?php //Establish a connection to the Database $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); //Select the MySQL database $db = mysql_select_db($Dbname, $conn); $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType"; $rs = mysql_query($sql, $conn) or die(mysql_error()); while($row = mysql_fetch_array($rs)) { $Type = $row['ItemType']; echo"<option value='$Type'"; if($ItemType == $Type) {echo"Selected";} echo">$Type</option>"; } mysql_close($conn); ?> </select> <br> <br> Price: <br> <input type="int" size="1" MAXLENGTH="3" name="Price1" value="<?php echo $_POST['Price1']?>"/>.<input type="int" MAXLENGTH="2" size="1" name="Price2" value="<?php echo $_POST['Price2']?>"/> <br> <br> NUS Price: <br> <input type="int" size="1" MAXLENGTH="3" name="NUSPrice1" value="<?php echo $_POST['NUSPrice1']?>"/>.<input type="int" MAXLENGTH="2" size="1" name="NUSPrice2" value="<?php echo $_POST['NUSPrice2']?>"/> <br> <br> Product Image: (Must be .jpg image type, 300x250 pixels in dimensions and less than 50Kb in size) <br> <input type="file" name="ProductImage" value="<?php echo $_FILES['ProductImage']['name']?>"/> <br> <br> Available Sizes: <br> <table id="Sizes"> <tr> <?php $X=0; while($X!=7) { $Size = $CBSizes[$X]; echo"<td>$Size:</td>"; echo"<td><input type='checkbox' name='Sizes[]' value='$Size'"; if($SizeA[$Size]==true){echo"Checked";}?> ></td> </tr> <tr> <?php $X++; } ?> </tr> </table> <br> Available Colours: <table><tr> <?php //Establish a connection to the Database $conn = mysql_connect($Host,$Username,$Password); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT AvailableColours FROM Colours ORDER BY AvailableColours"; $rs = mysql_query($sql, $conn) or die(mysql_error()); $NumberOfColours = mysql_num_rows($rs); $counter = 0; $X = 0; if ($result || (mysql_num_rows($rs) > 0)) { while ($row = mysql_fetch_assoc($rs)) { $AvailableColour = $row['AvailableColours']; if($counter%9==0&&$counter!=0) echo "</tr><tr>"; echo "<td><img src='/images/colours/$AvailableColour.gif' title='$AvailableColour'/><br />"; echo "<td><input type='checkbox' name='Colours[]' value='$AvailableColour'"; if($ColourA[$AvailableColour]==true) {echo"Checked";} echo "></td>"; $X++; ++$counter; } } echo "</tr></table>"; mysql_close($conn); ?> <br> <br> <?php } ?> <input type="submit" name="SubmitB" value="Submit"/> </form> </div> </body> </html>
  24. This is the other form that contains the .jpeg file upload and it is doing exactly the same thing as the .gif upload <?php include "connect_details.php"; $CBSizes = array("XS","Small", "Medium", "Large", "XL", "XXL", "3XL"); $Submit = $_POST['SubmitB']; $errors=0; if($_POST['SubmitB'] =="Submit") { $ClothingCode = $_POST['ClothingCode']; $Description = $_POST['Description']; $ItemType = $_POST['ItemType']; $Price1 = $_POST['Price1']; $Price2 = $_POST['Price2']; $NUSPrice1 = $_POST['NUSPrice1']; $NUSPrice2 = $_POST['NUSPrice2']; $ProductImage = $_FILES['ProductImage']['name']; $Max_Size = 51200; $Imagetype = $_FILES['ProductImage']['type']; $Imagesize = $_FILES['ProductImage']['size']; $image_temp = $_Files['ProductImage']['tmp_name']; $Img_Dimensions = getimagesize($image_temp); $width = $Img_Dimensions[0]; $height = $Img_Dimensions[1]; echo $Imagesize; echo"<br>"; echo $Imagetype; echo"<br>"; echo $width; echo"<br>"; echo $height; echo"<br>"; $dirupload = "../images/products/"; $NotExec = true; $AColours = $_POST['Colours']; $ASizes = $_POST['Sizes']; //ClothingCode Validation if(empty($ClothingCode)) { ?> <div style="position:absolute; top:10px; left:200px; width:550px"> <span class="errmsg">Please Enter the Clothing Code</span> </div> <?php $errors++; $Valid_ClothingCode = false; } //Description Validation if(empty($Description)) { ?> <div style="position:absolute; top:25px; left:200px; width:550px"> <span class="errmsg">Please Enter the Description</span> </div> <?php $errors++; $Valid_Description = false; } //Item Type Validation if(empty($ItemType)) { ?> <div style="position:absolute; top:40px; left:200px; width:550px"> <span class="errmsg">Please Select an Item Type!</span> </div> <?php $Valid_ItemType = false; $errors++; } //Price Validation if((empty($Price1)) || empty($Price2)) { ?> <div style="position:absolute; top:55px; left:200px; width:550px"> <span class="errmsg">Please Enter the Price</span> </div> <?php $errors++; $Valid_Price = false; } elseif((is_numeric($Price1) == false) || (is_numeric($Price2) == false)) { ?> <div style="position:absolute; top:55px; left:200px; width:550px"> <span class="errmsg">That is not a valid Price!</span> </div> <?php $errors++; $Valid_Price = false; } else { $Price = $Price1.".".$Price2; $Valid_Price = true; } //NUS Price Validation if((empty($NUSPrice1)) || empty($NUSPrice2)) { ?> <div style="position:absolute; top:70px; left:200px; width:550px"> <span class="errmsg">Please Enter the NUS Price</span> </div> <?php $errors++; $Valid_NUSPrice = false; } elseif((is_numeric($NUSPrice1) == false) || (is_numeric($NUSPrice2) == false)) { ?> <div style="position:absolute; top:70px; left:200px; width:550px"> <span class="errmsg">That is not a valid NUS Price!</span> </div> <?php $errors++; $Valid_NUSPrice = false; } else { $NUSPrice = $NUSPrice1.".".$NUSPrice2; $Valid_NUSPrice = true; } //Product Image Validation if (($Imagetype == "image/jpg") || ($Imagetype == "image/jpeg") || ($Imagetype == "image/jpe") && ($Imagesize < $Max_Size) && ($Img_Dimensions[0] <= 300) && ($Img_Dimensions[1] <=250)) { if (file_exists($dirupload . $_FILES['ProductImage']['name']."jpg")) { ?> <div style="position:absolute; top:85px; left:200px; width:550px"> <span class="errmsg">That file already exists!</span> </div> <?php $Valid_ProductImage = false; $errors++; } } else { $Valid_ColourImage = false; $errors++; ?> <div style="position:absolute; top:85px; left:200px; width:550px"> <span class="errmsg">Please Select a .jpg image file that is no more than 300x250 pixels in size, and is less than 50kb</span> </div> <?php } //Available Sizes Section if(count($ASizes) > 0) { foreach($ASizes AS $Sizes) { $Valid_ASizes=True; $SizeA[$Sizes]= true; $AvailableSizes .=$Sizes."?"; echo"<br>"; } } else { $Valid_ASizes=False; $errors++; ?> <div style="position:absolute; top:100px; left:200px; width:550px"> <span class="errmsg">Please select a size!</span> </div> <?php } //Available Colours Section if(count($AColours) > 0) { foreach($AColours AS $Colours) { $Valid_AColours=True; $ColourA[$Colours]= true; $AvailableColours .=$Colours."?"; echo"<br>"; } } else { $Valid_AColours=False; $errors++; ?> <div style="position:absolute; top:115px; left:200px; width:550px"> <span class="errmsg">Please select a Colour!</span> </div> <?php } // Upload Section if($errors==0) { } } ?> <html> <head> <title>Clothing Line</title> <link href="stylesheetCL.css" rel="stylesheet"> <?php require('jscript.inc') ?> </head> </head> <body> <?php require('menu.inc') ?> <div style="position:absolute; top:75px; left:200px; width:550px"> <form method="post" enctype="multipart/form-data" action='add_product_form.php'/> <?php if($_POST['SubmitB'] != "Submit") { ?> <br> Clothing Code: <br> <input type="text" MAXLENGTH="6" name="ClothingCode"/> <br> <br> Description: <br> <input type="text" MAXLENGTH="30" name="Description"/> <br> <br> Item Type: <br> <select name="ItemType"/> <option value="">Please Select an Item Type</option> <?php //Establish a connection to the Database $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); //Select the MySQL database $db = mysql_select_db($Dbname, $conn); $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType"; $rs = mysql_query($sql, $conn) or die(mysql_error()); while($row = mysql_fetch_array($rs)) { echo"<option value='{$row['ItemType']}'>{$row['ItemType']}</option>"; } mysql_close($conn); ?> </select> <br> <br> Price: <br> <input type="int" size="1" MAXLENGTH="3" name="Price1"/>.<input type="int" MAXLENGTH="2" size="1" name="Price2"/> <br> <br> NUS Price: <br> <input type="int" size="1" MAXLENGTH="3" name="NUSPrice1"/>.<input type="int" MAXLENGTH="2" size="1" name="NUSPrice2"/> <br> <br> Product Image: (Must be .jpg image type, 300x250 pixels in dimensions and less than 50Kb in size) <br> <input type="file" name="ProductImage"> <br> <br> Available Sizes: <br> <table id="Sizes"> <tr> <?php $X=0; while($X!=7) { $Size = $CBSizes[$X]; ?> <td><?php echo $Size?>:</td> <td><input type="checkbox" name="Sizes[]" value="<?php echo $Size?>"></td> </tr> <tr> <?php $X++; } ?> </tr> </table> <br> Available Colours: <table><tr> <?php //Establish a connection to the Database $conn = mysql_connect($Host,$Username,$Password); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT AvailableColours FROM Colours ORDER BY AvailableColours"; $rs = mysql_query($sql, $conn) or die(mysql_error()); $NumberOfColours = mysql_num_rows($rs); $counter = 0; if ($result || (mysql_num_rows($rs) > 0)) { while ($row = mysql_fetch_assoc($rs)) { if($counter%9==0&&$counter!=0) echo "</tr><tr>"; echo "<td><img src='/images/colours/{$row['AvailableColours']}.gif' title='{$row['AvailableColours']}'/><br />"; echo "<td><input type='checkbox' name='Colours[]' value='{$row['AvailableColours']}'></td>"; echo "</td>"; ++$counter; } } echo "</tr></table>"; mysql_close($conn); ?> <br> <br> <?php } elseif($_POST['SubmitB'] == "Submit") { ?> <br> Clothing Code: <br> <input type="text" MAXLENGTH="6" name="ClothingCode" value ="<?php echo $_POST['ClothingCode']; ?>"/> <br> <br> Description: <br> <input type="text" MAXLENGTH="30" name="Description" value ="<?php echo $_POST['Description']?>"/> <br> <br> Item Type: <br> <select name="ItemType" value="<?php echo $_POST['ItemType']?>"/> <option value="">Please Select an Item Type</option> <?php //Establish a connection to the Database $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); //Select the MySQL database $db = mysql_select_db($Dbname, $conn); $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType"; $rs = mysql_query($sql, $conn) or die(mysql_error()); while($row = mysql_fetch_array($rs)) { $Type = $row['ItemType']; echo"<option value='$Type'"; if($ItemType == $Type) {echo"Selected";} echo">$ItemType</option>"; } mysql_close($conn); ?> </select> <br> <br> Price: <br> <input type="int" size="1" MAXLENGTH="3" name="Price1" value="<?php echo $_POST['Price1']?>"/>.<input type="int" MAXLENGTH="2" size="1" name="Price2" value="<?php echo $_POST['Price2']?>"/> <br> <br> NUS Price: <br> <input type="int" size="1" MAXLENGTH="3" name="NUSPrice1" value="<?php echo $_POST['NUSPrice1']?>"/>.<input type="int" MAXLENGTH="2" size="1" name="NUSPrice2" value="<?php echo $_POST['NUSPrice2']?>"/> <br> <br> Product Image: (Must be .jpg image type, 300x250 pixels in dimensions and less than 50Kb in size) <br> <input type="file" name="ProductImage" value="<?php echo $_FILES['ProductImage']['name']?>"/> <br> <br> Available Sizes: <br> <table id="Sizes"> <tr> <?php $X=0; while($X!=7) { $Size = $CBSizes[$X]; echo"<td>$Size:</td>"; echo"<td><input type='checkbox' name='Sizes[]' value='$Size'"; if($SizeA[$Size]==true){echo"Checked";}?> ></td> </tr> <tr> <?php $X++; } ?> </tr> </table> <br> Available Colours: <table><tr> <?php //Establish a connection to the Database $conn = mysql_connect($Host,$Username,$Password); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT AvailableColours FROM Colours ORDER BY AvailableColours"; $rs = mysql_query($sql, $conn) or die(mysql_error()); $NumberOfColours = mysql_num_rows($rs); $counter = 0; $X = 0; if ($result || (mysql_num_rows($rs) > 0)) { while ($row = mysql_fetch_assoc($rs)) { $AvailableColour = $row['AvailableColours']; if($counter%9==0&&$counter!=0) echo "</tr><tr>"; echo "<td><img src='/images/colours/$AvailableColour.gif' title='$AvailableColour'/><br />"; echo "<td><input type='checkbox' name='Colours[]' value='$AvailableColour'"; if($ColourA[$AvailableColour]==true) {echo"Checked";} echo "></td>"; $X++; ++$counter; } } echo "</tr></table>"; mysql_close($conn); ?> <br> <br> <?php } ?> <input type="submit" name="SubmitB" value="Submit"/> </form> </div> </body> </html>
×
×
  • 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.