I am trying to add some information to my database. The code executes but it does not show on the database. I would love if somebody could help me out! Thank you very much! Happy Holidays :)!
I tried running the program with default values. I have tried different syntax as well. I tried swapping the places of header and mysqli_close().
$conn = mysqli_connect("localhost", "root", "root", "Store");
$nameTshirt = 'T-Shirt NDOE';
$priceTshirt = 35.00;
$nameAlbum = 'Thousands of Scars Album';
$size = $_GET['size'];
$quantity = $_GET['quantityOne'];
$sql = "INSERT INTO shoppingCart(name, size, quantity, price)
VALUES ('T-Shirt NDOE', 'XL', '3', 35.00);";
mysqli_query($conn, $sql);
header("Location: Store - EN.php?item=added");
mysqli_close($conn);
Take the user's input from this form:
<form action="addTshirt.php">
<div class="item">
<img src="../Images/store/NDOE - T-SHIRT-b-600x600.jpg" width="300" height="300" alt="NDOE T-Shirt image" class="storeimage">
</div>
<div class = "name"> <b>NDOE T-Shirt</b></div>
<div class = "price">35.00</div>
<div class = "name2">Size:
<select class = "drop" name = "size">
<option value = "select">Select</option>
<option value = "S">S</option>
<option value = "M">M</option>
<option value = "L">L</option>
<option value = "XL">XL</option>
</select>
</div>
<div class="name2">Quantity:
<select class = "quantity" name = "quantityOne">
<option value = "0">0</option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
<option value = "4">4</option>
<option value = "5">5</option>
<option value = "6">6</option>
<option value = "7">7</option>
<option value = "8">8</option>
<option value = "9">9</option>
<option value = "10">10</option>
</select></div>
<div class="wrapper">
<input type="submit" class = "buttonP" name="tshirtButton" value="Add to cart">
</div>
</div>
</form>
</div>
</td>
Aucun commentaire:
Enregistrer un commentaire