0

Firstly sorry if the title make some of you confuse ... here's the real problem.

I am developing a system that generates a receipt from HTML Form. The real problem is that I don't know how to get all descriptions because I'm using multiple input controls on the form.

In add.php, there are some description boxes where staff can enter the purchased info. I'm using Input. The code's are:

<input type='text' name='desc[1]' size='40px'><!-- (I'll copy paste it 9 times) -->

This is the only place to enter all info, then it will redirect to view the order info.

I can echo everything using $_REQUEST, but I don't know how to echo this. People say it's an array but I don't understand it that much.

Here some code:

Add.php

<?php

include 'server.php';
session_start();
$id = $_SESSION['id'];

if (isset($_POST['submit'])) {
    $order = $_POST['order'];
    $name = $_POST['name'];
    $tel = $_POST['tel'];
    $orderdate = $_POST['orderdate'];
    $firstfit = $_POST['firstfit'];
    $event = $_POST['event'];
    $desc = $_POST['desc'];
    $color = $_POST['color'];
    $address = $_POST['address'];

    $syntax = "INSERT INTO `client` (`order`,`name`,`tel`,`orderdate`,`firstfit`,`event`,`desc`,`color`) VALUES ('$order','$name','$tel','$orderdate','$firstfit','$event','$desc','$color')";
    $insert = mysqli_query($config, $syntax);
    header("Location: do.php");
}

Then here's the input

<tr>
    <th>DESCRIPTION :</th>
    <td>
        <input type="text" name="desc[1]" size="90px"><br>
        <input type="text" name="desc[2]" size="90px"><br>
        <input type="text" name="desc[3]" size="90px"><br>
        <input type="text" name="desc[4]" size="90px"><br>
        <input type="text" name="desc[5]" size="90px"><br>
        <input type="text" name="desc[6]" size="90px"><br>
        <input type="text" name="desc[7]" size="90px"><br>
        <input type="text" name="desc[8]" size="90px"><br>
        <input type="text" name="desc[9]" size="90px"><br>
    </td>
</tr>

So how can I echo out all the 9 different descriptions into the receipt? I'm sorry if this question is not clear because I'm still a beginner :-(

2
  • You should consult a tutorial. Your script is wide open to SQL injections. The query needs to be parameterized. Your $desc is an array and needs to be iterated over. $syntax is a bad name for a variable. Once you get to outputting look at XSS injections, you'll need to prevent those as well. It seems like you are a bit away from outputting though. Commented Jan 2, 2020 at 2:57
  • I'll just start a new semester (Introduction to Web Development). Everything new to me and this is my side project. Thank's for your advised. Really appreciate it Commented Jan 2, 2020 at 3:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.