Jump to content

Setzi138

Members
  • Posts

    14
  • Joined

  • Last visited

Posts posted by Setzi138

  1. I always get the following warnings and i have no idea why.

        Warning: Undefined array key "username" in C:\xampp\htdocs\Kulinarik\save_order.php on line 2

        Warning: Undefined array key "item" in C:\xampp\htdocs\Kulinarik\save_order.php on line 3

        Warning: Undefined array key "quantity" in C:\xampp\htdocs\Kulinarik\save_order.php on line 4

        Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:\xampp\htdocs\Kulinarik\save_order.php:13 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Kulinarik\save_order.php on line 13

    Here comes the code that belongs to the errors

    Html

                      <table class="u-table-entity" src="jquery.js" action="save_order.php" method="POST">
    
                        <script scr="calculation.js"></script>
                        
                        <colgroup>
                          <col width="20%">
                          <col width="2.1%">
                          <col width="22%">
                          <col width="21.7%">
                          <col width="34.2%">
                        </colgroup>
                        <tbody class="u-table-alt-grey-5 u-table-body">
                          <tr style="height: 55px;">
                            <b>
                            <th class="u-table-cell u-table-cell-1"><b>Produkt</b><span style="font-weight: 700;"></span>
                            </th>
                            <th class="u-table-cell"></th>
                            <th class="u-table-cell u-table-cell-3"><b>Einzelpreis</b></th>
                            <th class="u-table-cell u-table-cell-4"><b>Menge</b></th>
                            <th class="u-table-cell u-table-cell-5"><b>Gesamtpreis</b></th>
                            </b>
                          </tr>
    
                          <tr style="height: 55px;">
                            <td class="u-table-cell">
                              <input name="item" value="Kornspitz"></input>
                            </td>
                            <td class="u-table-cell"></td>
                            <td class="u-table-cell">
                              <input type="text" class="price" value="11.39" readonly/>
                            </td>
                            <td class="u-table-cell">
                              <input type="text" class="quantity"/> 
                            </td>
                            <td class="u-table-cell">
                              <input type="text" class="total" readonly/>
                            </td>
                          </tr>
    
    
    
    
    
    
    
            <a href="save_order.php" class="u-border-none u-btn u-button-style u-custom-color-1 u-btn-2" type="submit">Bestellen<br>

    php

    <?php
    	$username = $_POST['username'];
    	$item = $_POST['item'];
    	$quantity = $_POST['quantity'];
    
    	// Database connection
    	$conn = new mysqli('localhost','root','123456','orders');
    	if($conn->connect_error){
    		echo "$conn->connect_error";
    		die("Connection Failed : ". $conn->connect_error);
    	} else {
    		$stmt = $conn->prepare("insert into orders(username, item, quantity) values(?, ?, ?)");
    		$stmt->bind_param("sssssi", $username, $item, $quantity);
    		$execval = $stmt->execute();
    		echo $execval;
    		echo "Bestellung Erfolgreich";
    		$stmt->close();
    		$conn->close();
    	}
    ?>

     

  2. Hi experts

    I want to create a table with a fixed price, an input field  where someone can enter a value and a column wit the total (price*quantity)

    The problem i have is that the code i wrot works but only with integers. it does not read after the comma.
    So if i enter a price of 4.39 it calculates with 4.

     

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.3.js"></script>
        <script type="text/javascript">
            $(function () {
                $('.price,.quantity').on('keyup', function () {
                    var row = $(this).closest('tr');
                    var price = $(row).find('.price').val() == '' ? 0 : $(row).find('.price').val();
                    var quantity = $(row).find('.quantity').val() == '' ? 0 : $(row).find('.quantity').val();
                    $(row).find('.total').val(parseInt(isNaN(price) ? 0 : price) * parseInt(isNaN(quantity) ? 0 : quantity));
                });
            });
        </script>
    </head>
    <body>
        <div>
            <table>
                <tr>
                    <th>Name</th>
                    <th>Price</th>
                    <th>Quantity</th>
                    <th>Total</th>
                </tr>
                <tr>
                    <td>Chai</td>
                    <td><input type="text" class="price" value="1.39" readonly/></td>
                    <td><input type="text" class="quantity" /></td>
                    <td><input type="text" class="total" readonly/></td>
                </tr>
                <tr>
                    <td>Chang</td>
                    <td><input type="text" class="price" value="2.39" readonly/></td>
                    <td><input type="text" class="quantity" /></td>
                    <td><input type="text" class="total" readonly/></td>
                </tr>
                <tr>
                    <td>Aniseed Syrup</td>
                    <td><input type="text" class="price" value="4.39" readonly/></td>
                    <td><input type="text" class="quantity" /></td>
                    <td><input type="text" class="total" readonly/></td>
                </tr>
            </table>
        </div>
    </body>
    </html>

    EDIT

    Also if i set the type to "decimal" or "number" it doesn't work

  3. I'm really a beginner with javascript 
    i would need a little more details 😅

    in the file below you cann see the site 

    the task is that i watn the people to manuelly insert into "Menge" german for quantity

    and the "Gesamtpreis" Total should be calculated automatically form "Einzelpreis"*"Menge" or price*quantity

     

    <tr style="height: 55px;">
                            <b>
                            <td class="u-table-cell u-table-cell-1"><b>Produkt</b><span style="font-weight: 700;"></span>
                            </td>
                            <td class="u-table-cell"></td>
                            <td class="u-table-cell u-table-cell-3"><b>Einzelpreis</b></td>
                            <td class="u-table-cell u-table-cell-4"><b>Menge</b></td>
                            <td class="u-table-cell u-table-cell-5"><b>Gesamtpreis</b></td>
                            </b>
                          </tr>
                          <tr style="height: 55px;">
                            <td class="u-table-cell">Kornspitz</td>
                            <td class="u-table-cell"></td>
                            <td class="u-table-cell">
                              <p value="1,39">1,39 €</p>
                            </td>
                            <td class="u-table-cell">
                              <form id="Menge">
                                <input type="number" min="0" id="quantity" value="0" step="1.0">
                              </form>
                            </td>
                            <td class="u-table-cell">
                              <form id="sum">
                                <p><output id="field_sum" for="quantity">0</output></p>
                              </form>
                            </td>
                          </tr>

     

     

    Unbenannt01.PNG

  4. <tr style="height: 55px;">
                            <td class="u-table-cell">Pizza</td>
                            <td class="u-table-cell"></td>
                            <td class="u-table-cell">5$</td>
                            <td class="u-table-cell">
                              <form id="quantity">
                                <input type="number" min="0" id="quantity" value="0" step="1.0">
                              </form>
                            </td>
                            <td class="u-table-cell"> ##Calculation here## </td>
                          </tr>

    I want that the price is fixed and the user inserts the amount he wants in the last column should then be calculated Amount*price and print it out in the table

    this should happe live without refreshing

     

    is there a possibility to do it with php or any other way without javascript ?

  5. <tbody class="u-table-alt-grey-5 u-table-body">
                          <tr style="height: 55px;">
                            <b>
                            <td class="u-table-cell u-table-cell-1"><b>Produkt</b><span style="font-weight: 700;"></span>
                            </td>
                            <td class="u-table-cell"></td>
                            <td class="u-table-cell u-table-cell-3"><b>Einzelpreis</b></td>
                            <td class="u-table-cell u-table-cell-4"><b>Menge</b></td>
                            <td class="u-table-cell u-table-cell-5"><b>Gesamtpreis</b></td>
                            </b>
                          </tr>
                          <tr style="height: 55px;">
                            <td class="u-table-cell"> Chillistangerl</td>
                            <td class="u-table-cell"></td>
                            <td class="u-table-cell"> € 1,39</td>
                            <td class="u-table-cell"><input type='number' name='Menge' size='20'><br><br></td>
                            <td class="u-table-cell"></td>
                          </tr>

     

    the input number sticks to the top of the table 

    how can i center it ?

  6. just one other question

    is there a pure php way to redirect to the homepage after login?

     i tried with java but it didn#t worked out

    <?php
        session_start();
    ?>
    
    <?php
    
    	$ldap_dn = "uid=".$_POST["username"].",dc=example,dc=com";
    	$ldap_password = $_POST["password"];
    	
    	$ldap_con = ldap_connect("ldap.forumsys.com");
    	ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);
    
    	if(@ldap_bind($ldap_con,$ldap_dn,$ldap_password))
    		{
    		$_SESSION['username'] = $_POST["username"];
    		echo '<script type="text/javascript">window.open("C:\xampp\htdocs\Kulinarik\Startseite.php")</script>';
    
    		}
    
    	else
    		{
    		echo "Invalid Credential";
    		}
    ?>

     

  7. ahhh

    Thank you

    it works now 

     

    <?php
        session_start();
    ?>
    
    <?php
    
    	$ldap_dn = "uid=".$_POST["username"].",dc=example,dc=com";
    	$ldap_password = $_POST["password"];
    	
    	$ldap_con = ldap_connect("ldap.forumsys.com");
    	ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);
    
    	if(@ldap_bind($ldap_con,$ldap_dn,$ldap_password))
    		{
    		$_SESSION['username'] = $_POST["username"];
    		echo($_SESSION['username']);
    		}
    
    	else
    		{
    		echo "Invalid Credential";
    		}
    ?>

     

  8. Changed it a bit now it works better but another Error arised

    Warning: Array to string conversion in C:\xampp\htdocs\Kulinarik\ldap.php on line 16
    Array

     

    <?php
        session_start();
    ?>
    
    <?php
    
    	$ldap_dn = "uid=".$_POST["username"].",dc=example,dc=com";
    	$ldap_password = $_POST["password"];
    	
    	$ldap_con = ldap_connect("ldap.forumsys.com");
    	ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);
    
    	if(@ldap_bind($ldap_con,$ldap_dn,$ldap_password))
    		{
    		$_SESSION['username'] = ["username"];
    		echo $_SESSION['username'];
    		}
    
    	else
    		{
    		echo "Invalid Credential";
    		}
    ?>

     

  9. I want to create a login form that uses an Ldap for authentication

    after that the name should be shown at the top of the page 

    for that i want to create a session

    this is the code

    <?php
        session_start();
    ?>
    
    <?php
    
    	$ldap_dn = "uid=".$_POST["username"].",dc=example,dc=com";
    	$ldap_password = $_POST["password"];
    	
    	$ldap_con = ldap_connect("ldap.forumsys.com");
    	ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);
    
    	if(@ldap_bind($ldap_con,$ldap_dn,$ldap_password))
    		$_SESSION['username'] = ["username"];
    		echo $_SESSION['username'];
    
    	else
    		echo "Invalid Credential";
    
    ?>

    but there are 2 warnings which i don't understand

     

    Warning: Undefined array key "username" in C:\xampp\htdocs\Kulinarik\ldap.php on line 15
    Parse error: syntax error, unexpected token "else", expecting end of file in C:\xampp\htdocs\Kulinarik\ldap.php on line 17

     

    i would really appreciate your help 
    Thank you

×
×
  • 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.