Search the Community
Showing results for tags '#mysql'.
-
I'm trying to get the login feature for my website and I feel I'm almost there.. but whenever I try the feature with a valid username and password I get the echo ("Sorry, your credentials are invalid, Please try again") for an invalid username and/or password. <?php error_reporting(E_ALL); include("function.php"); //connection to Database is defined in function.php $host = "localhost"; //Host Name $username = "username"; //MySQL username $password = "password"; //MySQL password $db_name = "database"; // Database Name $tab_name = "users"; // Table Name // Grab User submitted information $username = $_POST["username"]; $password = $_POST["password"]; // Connect to the database $con = mysql_connect("localhost","root",""); // Make sure we connected succesfully if(! $con) { die('Connection Failed'.mysql_error()); } // Select the database to use mysql_select_db("database")or die("cannot connect to DB"); $sql = "SELECT * FROM $tab_name WHERE username='$username' and password='$password' limit 1"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)); if($row["username"]==$username && $row["password"]==$password) header("Location: http://localhost/SITE/Homepage.htm"); //echo"You are a validated user."; else echo"Sorry, your credentials are not valid, Please try again."; ?> Any suggestions that can ameliorate my situation would be greatly appreciated! (Been working on this for more than 2 weeks )
-
the issue is, i was trying to use a manual database connection. i design a form and i create a new file for the php/mysql codding. when i run the form using(dreamweaver and dispaly it in chrome)and fill in every fields and click button submit it will display the php/mysql codding the same way i coded it. how can i resolve that.
-
Hey guys i have got some PHP Code that i use its for an order page. When i place an order on my form it gets the Customer Information. But when i try to put an order in for the checkbox items it only gets the 1st item that is clicked in the checkbox and does not get the quantity. Is there anything that i am doing wrong in my code? form action="localhost" method="post"> <tr> <th>Shirts</th> <th>Quantity</th> </tr> <tr> <td> <br /> <input type="checkbox" name="items" value="SH01" /><label for="rd1">Obey T-Shirt: $9.99</label></div> <br /> <input type="checkbox" name="items" value="SH02" /><label for="rd1">Obey Professor: $9.99</label></div> <br /> <input type="checkbox" name="items" value="SH03" /><label for="rd1">Hustle T-Shirt: $9.99</label></div> <br /> <input type="checkbox" name="items" value="SH04" /><label for="rd1">Hip-Hop Support: $9.99</label></div> <br /> <input type="checkbox" name="items" value="SH05" /><label for="rd1">90's Shirt: $9.99</label></div> <br /> <input type="checkbox" name="items" value="SH06" /><label for="rd1">DOPE Shirt: $9.99</label></div> <br /> <br /> </td> <td> <br /> <input type="text" name="qty[SH01]" size ="2"/><br/> <input type="text" name="qty[SH02]" size="2"/><br/> <input type="text" name="qty[SH03]" size="2"/><br/> <input type="text" name="qty[SH04]" size="2"/><br/> <input type="text" name="qty[SH05]" size="2"/><br/> <input type="text" name="qty[SH06]" size="2"/><br/> <br /> </td> </tr> <tr> <td> <br /> <input type="checkbox" name="items" value="SO1" /><label for="rd1">Shoe - Red Lace: $19.99</label></div><br /> <input type="checkbox" name="items" value="SO2" /><label for="rd1">Shoe - Red High Top: $19.99</label></div><br /> <input type="checkbox" name="items" value="SO3" /><label for="rd1">Shoe - White: $19.99</label></div><br /> <input type="checkbox" name="items" value="SO4" /><label for="rd1">Shoe - Black: $19.99</label></div><br /> <input type="checkbox" name="items" value="SO5" /><label for="rd1">Shoe - Black High Top: $19.99</label></div><br /> <input type="checkbox" name="items" value="SO6" /> <label for="rd1">Red Basketball: $19.99</label></div><br /> <br /> </td> <td> <br /> <input type="text" name="qty[SO1]" size ="2"/><br/> <input type="text" name="qty[SO2]" size="2"/><br/> <input type="text" name="qty[SO3]" size="2"/><br/> <input type="text" name="qty[SO4]" size="2"/><br/> <input type="text" name="qty[SO5]" size="2"/><br/> <input type="text" name="qty[SO6]" size="2"/><br/> <br /> </td> </tr> <tr> <td> <br /> <input type="checkbox" name="items" value="SN1" /> <label for="rd1">Snapback Bullets: $29.99</label></div><br /> <input type="checkbox" name="items" value="SN2" /><label for="rd1">Snapback Grey: $29.99</label></div><br /> <input type="checkbox" name="items" value="SN3" /><label for="rd1">Snapback Bulls: $29.99</label></div><br /> <input type="checkbox" name="items" value="SN4" /><label for="rd1">Snapback Miami: $29.99</label></div><br /> <input type="checkbox" name="items" value="SN5" /><label for="rd1">Snapback Nets: $29.99</label></div><br /> <input type="checkbox" name="items" value="SN6" /><label for="rd1">Snapback Obey: $29.99</label></div><br /> <br /> </td> <td> <br /> <input type="text" name="qty[SN1]" size ="2"/><br/> <input type="text" name="qty[SN2]" size="2"/><br/> <input type="text" name="qty[SN3]" size="2"/><br/> <input type="text" name="qty[SN4]" size="2"/><br/> <input type="text" name="qty[SN5]" size="2"/><br/> <input type="text" name="qty[SN6]" size="2"/><br/> <br /> </td> </tr> </tr> </table> <br /> <h3 class="c4">Please Enter Customer Details</h3> <p class="normal"> <label><input type = "text" name = "custName" />Name (last name, first name, middle initial)</label><br /> <label><input type = "text" name = "phone" />Phone number (ddd-ddd-dddd)</label><br /> <label><input type = "text" name = "custEmail" />Insert E-Mail Address<br /></label> </p> <script type="text/javascript" src="validatorr.js"></script> <input type="submit" name="submit"> </form> <?php if (isset($_POST['submit'])) { $con = mysql_connect('localhost','username','password'); if (!$con) { die("Could Not Connect: " . mysql_error()); } mysql_select_db("$$", $con); $sql = "INSERT INTO Order_Information(Order_ID,Order_Items,Order_Quantity) VALUES (null,'$_POST[items]','$_POST[qty]')"; mysql_query($sql,$con); $sql = "INSERT INTO Customer_Information(Cust_ID,Cust_Name,Cust_Phone,Cust_Email) VALUES (null, '$_POST[custName]','$_POST[phone]','$_POST[custEmail]')"; mysql_query($sql,$con); mysql_close($con); } ?>