Which should I use in input tag

I am confused why should I put input name and ID in the input tag . when I just put either one of them, the code still works
which attribute does the POST need?

Your question does not make sense. We can not understand it because you did not show us any code!
Normally, in posting from a form, you have something like this:
< input type=“text” name=“somename” value=“default value” >
Then, in your PHP code, you read it like this:
$somename = filter_input(INPUT_POST, “somename”);
This reads the data from the posted form and puts it into a usable PHP variable.

The ID in an HTML input clause is used if you need to access it by certain libraries or Javascript or JQuery. ID’s in an input field is not needed unless you need to access it in the DOM. Guessing that is what you are asking.

Why would you say this is an inappropriate answer? You did not show the code you asked about. Also, I answered the question for you. This is a code site. We help you with your code.

But, here is more info if you feel I did not answer it clear enough for you: HTML-ID

1.) ALWAYS post codes examples… even if just for communication purposes.

2.) For the most part the NAME attribute is what is needed/used for $_POST data. ID is usually (from my experience) used more on the front end side of things…

However… it also depends on HOW you are processing the data… if use an AJAX approach… ID might be a more common approach to target the elements and pass on the values to an external PHP script to process/parse…etc…

@whispers thank you. I have experimented yesterday and I found out that what is really important in getting the data is the name attribute and the id attribute is mostly for CSS, I just forgot to update my post but thanks anyway as it concluded my assumption.

I usually put pics of my code but some other guy complained why I kept posting my code and now, someone is also complaining that I didn’t show my code.

Any complaints about pictures of your code, vs the actual code, are because we cannot help you with pictures of your code. We cannot copy/paste any line(s) of a picture if we need to quote just a part of it, test what it actually does, or post a corrected version of it. Post your actual code, not pictures of it.

1 Like

Correct

PICS of code = no good (worthless)

PASTING real code = what is being requested

When pasting code you can either indent every line by four spaces, or use three ` characters at the start and end:

```
$codeGoesHere;
```
Sponsor our Newsletter | Privacy Policy | Terms of Service