How to pass a POST variable without a form?How do JavaScript closures work?How to horizontally center a <div>?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I modify the URL without reloading the page?How to check whether a checkbox is checked in jQuery?How to check whether a string contains a substring in JavaScript?Reference — What does this symbol mean in PHP?How do I remove a particular element from an array in JavaScript?

Most valuable information/technology for rebuilding after the apocalypse?

Why do the Tie-fighter pilot helmets have similar ridges as the rebels?

What is the Leave No Trace way to dispose of coffee grounds?

How many sets of dice do I need for D&D?

What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?

YA book about blind creatures that live underground and take kid's eyes

Should I refuse to be named as co-author of a low quality paper?

What do Birth, Age, and Death mean in the first noble truth?

Remove border lines of SRTM tiles rendered as hillshade

What do you call the action of "describing events as they happen" like sports anchors do?

How can I remove material from this wood beam?

Is there a DSLR/mirorless camera with minimal options like a classic, simple SLR?

Proving that a Russian cryptographic standard is too structured

If I had a daughter who (is/were/was) cute, I would be very happy

Piano: good exercises for runs and navigation

noalign caused by multirow and colors

NUL delimited variable

Augment Export function to support custom number formatting

Part of my house is inexplicably gone

Print "N NE E SE S SW W NW"

I've been given a project I can't complete, what should I do?

Does putting salt first make it easier for attacker to bruteforce the hash?

bash vs. zsh: What are the practical differences?

A life of PhD: is it feasible?



How to pass a POST variable without a form?


How do JavaScript closures work?How to horizontally center a <div>?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I modify the URL without reloading the page?How to check whether a checkbox is checked in jQuery?How to check whether a string contains a substring in JavaScript?Reference — What does this symbol mean in PHP?How do I remove a particular element from an array in JavaScript?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















What is the best way to use a PHP table to hold comments from multiple different sections, and be able to distinguish between each different comments section? Is there some way to pass POST data without the need of a form?



Is there some way for me to distinguish between these two forms? Should I be using Javascript and distinguishing by the id of the forms, or is there a cleaner way?



<form action="SubmitComment.php" method="post" id="comments1">
<h3>Name:</h3><input type="text" name="name" cols="100">
<h3>Comment:</h3><input type="text" name="comment" cols="100">
<textarea rows=4 cols="100" placeholder="Enter text here!"></textarea>
<?php $_POST['section'] = 1; ?>
</form>

<!-- I want to be able to distinguish between these two forms. -->

<form action="SubmitComment.php" method="post" id="comments2">
<h3>Name:</h3><input type="text" name="name" cols="100">
<h3>Comment:</h3><input type="text" name="comment" cols="100">
<textarea rows=4 cols="100" placeholder="Enter text here!"></textarea>
<?php $_POST['section'] = 2; ?>
</form>









share|improve this question

















  • 2





    Ajax (XMLHTTPRequest) can send data without using a HTML form.. Only problem that you need a HTTP form and input if you want to ask information from the user

    – Raymond Nijland
    Mar 24 at 22:27











  • most common way when you use two forms on one page and or submit to one .php file you add a <input type="hidden" value="<form_id>" /> to the form

    – Raymond Nijland
    Mar 24 at 22:30


















0















What is the best way to use a PHP table to hold comments from multiple different sections, and be able to distinguish between each different comments section? Is there some way to pass POST data without the need of a form?



Is there some way for me to distinguish between these two forms? Should I be using Javascript and distinguishing by the id of the forms, or is there a cleaner way?



<form action="SubmitComment.php" method="post" id="comments1">
<h3>Name:</h3><input type="text" name="name" cols="100">
<h3>Comment:</h3><input type="text" name="comment" cols="100">
<textarea rows=4 cols="100" placeholder="Enter text here!"></textarea>
<?php $_POST['section'] = 1; ?>
</form>

<!-- I want to be able to distinguish between these two forms. -->

<form action="SubmitComment.php" method="post" id="comments2">
<h3>Name:</h3><input type="text" name="name" cols="100">
<h3>Comment:</h3><input type="text" name="comment" cols="100">
<textarea rows=4 cols="100" placeholder="Enter text here!"></textarea>
<?php $_POST['section'] = 2; ?>
</form>









share|improve this question

















  • 2





    Ajax (XMLHTTPRequest) can send data without using a HTML form.. Only problem that you need a HTTP form and input if you want to ask information from the user

    – Raymond Nijland
    Mar 24 at 22:27











  • most common way when you use two forms on one page and or submit to one .php file you add a <input type="hidden" value="<form_id>" /> to the form

    – Raymond Nijland
    Mar 24 at 22:30














0












0








0








What is the best way to use a PHP table to hold comments from multiple different sections, and be able to distinguish between each different comments section? Is there some way to pass POST data without the need of a form?



Is there some way for me to distinguish between these two forms? Should I be using Javascript and distinguishing by the id of the forms, or is there a cleaner way?



<form action="SubmitComment.php" method="post" id="comments1">
<h3>Name:</h3><input type="text" name="name" cols="100">
<h3>Comment:</h3><input type="text" name="comment" cols="100">
<textarea rows=4 cols="100" placeholder="Enter text here!"></textarea>
<?php $_POST['section'] = 1; ?>
</form>

<!-- I want to be able to distinguish between these two forms. -->

<form action="SubmitComment.php" method="post" id="comments2">
<h3>Name:</h3><input type="text" name="name" cols="100">
<h3>Comment:</h3><input type="text" name="comment" cols="100">
<textarea rows=4 cols="100" placeholder="Enter text here!"></textarea>
<?php $_POST['section'] = 2; ?>
</form>









share|improve this question














What is the best way to use a PHP table to hold comments from multiple different sections, and be able to distinguish between each different comments section? Is there some way to pass POST data without the need of a form?



Is there some way for me to distinguish between these two forms? Should I be using Javascript and distinguishing by the id of the forms, or is there a cleaner way?



<form action="SubmitComment.php" method="post" id="comments1">
<h3>Name:</h3><input type="text" name="name" cols="100">
<h3>Comment:</h3><input type="text" name="comment" cols="100">
<textarea rows=4 cols="100" placeholder="Enter text here!"></textarea>
<?php $_POST['section'] = 1; ?>
</form>

<!-- I want to be able to distinguish between these two forms. -->

<form action="SubmitComment.php" method="post" id="comments2">
<h3>Name:</h3><input type="text" name="name" cols="100">
<h3>Comment:</h3><input type="text" name="comment" cols="100">
<textarea rows=4 cols="100" placeholder="Enter text here!"></textarea>
<?php $_POST['section'] = 2; ?>
</form>






javascript php html mysql






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 22:11









Dominic LopezDominic Lopez

82




82







  • 2





    Ajax (XMLHTTPRequest) can send data without using a HTML form.. Only problem that you need a HTTP form and input if you want to ask information from the user

    – Raymond Nijland
    Mar 24 at 22:27











  • most common way when you use two forms on one page and or submit to one .php file you add a <input type="hidden" value="<form_id>" /> to the form

    – Raymond Nijland
    Mar 24 at 22:30













  • 2





    Ajax (XMLHTTPRequest) can send data without using a HTML form.. Only problem that you need a HTTP form and input if you want to ask information from the user

    – Raymond Nijland
    Mar 24 at 22:27











  • most common way when you use two forms on one page and or submit to one .php file you add a <input type="hidden" value="<form_id>" /> to the form

    – Raymond Nijland
    Mar 24 at 22:30








2




2





Ajax (XMLHTTPRequest) can send data without using a HTML form.. Only problem that you need a HTTP form and input if you want to ask information from the user

– Raymond Nijland
Mar 24 at 22:27





Ajax (XMLHTTPRequest) can send data without using a HTML form.. Only problem that you need a HTTP form and input if you want to ask information from the user

– Raymond Nijland
Mar 24 at 22:27













most common way when you use two forms on one page and or submit to one .php file you add a <input type="hidden" value="<form_id>" /> to the form

– Raymond Nijland
Mar 24 at 22:30






most common way when you use two forms on one page and or submit to one .php file you add a <input type="hidden" value="<form_id>" /> to the form

– Raymond Nijland
Mar 24 at 22:30













1 Answer
1






active

oldest

votes


















2














There is a way to distinguish forms using



<input type="submit" name="form" value="form1">



to send data, in that way you can read $_POST['form'] value and check what form it is



If you want to send data without form you can use ajax with Javascript.






share|improve this answer

























  • "If you want to send data without form you can use ajax with javascript" Yes but you would still need a form with inputs to ask information.

    – Raymond Nijland
    Mar 24 at 22:31






  • 1





    I mean, you can use input without <form> and without standard form methods

    – pavelbere
    Mar 24 at 22:49











  • "I mean, you can use input without <form> and without standard form methods" that is invalid html, and you will have to ask yourself how browsers will handle that case and styling with css and javascript handling most likely it will work because most browsers are designed to display invalid html or fix broken/invalid html

    – Raymond Nijland
    Mar 24 at 22:50












  • @RaymondNijland - is it your intention to claim that the <form> element is the only one that accepts "phrasing content"? If this is not the case, your assertion that the html resultant from pavelbere's suggestion would be invalid appears incorrect. As stated at MDN, any element permitted to accept phrasing content can legally be the parent of an <input> element. Forms are no longer a requirement. ;) Buttons too, need only be parented by something capable of holding "prasing content"

    – enhzflep
    Mar 24 at 23:49











  • yes that direction i was going @enhzflep well then it seams that W3C HTML 5 specs have loosed up that, because it was first required you placed the input tag in a form tag before it was valid html, iam pretty sure of that.

    – Raymond Nijland
    Mar 24 at 23:58












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329082%2fhow-to-pass-a-post-variable-without-a-form%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














There is a way to distinguish forms using



<input type="submit" name="form" value="form1">



to send data, in that way you can read $_POST['form'] value and check what form it is



If you want to send data without form you can use ajax with Javascript.






share|improve this answer

























  • "If you want to send data without form you can use ajax with javascript" Yes but you would still need a form with inputs to ask information.

    – Raymond Nijland
    Mar 24 at 22:31






  • 1





    I mean, you can use input without <form> and without standard form methods

    – pavelbere
    Mar 24 at 22:49











  • "I mean, you can use input without <form> and without standard form methods" that is invalid html, and you will have to ask yourself how browsers will handle that case and styling with css and javascript handling most likely it will work because most browsers are designed to display invalid html or fix broken/invalid html

    – Raymond Nijland
    Mar 24 at 22:50












  • @RaymondNijland - is it your intention to claim that the <form> element is the only one that accepts "phrasing content"? If this is not the case, your assertion that the html resultant from pavelbere's suggestion would be invalid appears incorrect. As stated at MDN, any element permitted to accept phrasing content can legally be the parent of an <input> element. Forms are no longer a requirement. ;) Buttons too, need only be parented by something capable of holding "prasing content"

    – enhzflep
    Mar 24 at 23:49











  • yes that direction i was going @enhzflep well then it seams that W3C HTML 5 specs have loosed up that, because it was first required you placed the input tag in a form tag before it was valid html, iam pretty sure of that.

    – Raymond Nijland
    Mar 24 at 23:58
















2














There is a way to distinguish forms using



<input type="submit" name="form" value="form1">



to send data, in that way you can read $_POST['form'] value and check what form it is



If you want to send data without form you can use ajax with Javascript.






share|improve this answer

























  • "If you want to send data without form you can use ajax with javascript" Yes but you would still need a form with inputs to ask information.

    – Raymond Nijland
    Mar 24 at 22:31






  • 1





    I mean, you can use input without <form> and without standard form methods

    – pavelbere
    Mar 24 at 22:49











  • "I mean, you can use input without <form> and without standard form methods" that is invalid html, and you will have to ask yourself how browsers will handle that case and styling with css and javascript handling most likely it will work because most browsers are designed to display invalid html or fix broken/invalid html

    – Raymond Nijland
    Mar 24 at 22:50












  • @RaymondNijland - is it your intention to claim that the <form> element is the only one that accepts "phrasing content"? If this is not the case, your assertion that the html resultant from pavelbere's suggestion would be invalid appears incorrect. As stated at MDN, any element permitted to accept phrasing content can legally be the parent of an <input> element. Forms are no longer a requirement. ;) Buttons too, need only be parented by something capable of holding "prasing content"

    – enhzflep
    Mar 24 at 23:49











  • yes that direction i was going @enhzflep well then it seams that W3C HTML 5 specs have loosed up that, because it was first required you placed the input tag in a form tag before it was valid html, iam pretty sure of that.

    – Raymond Nijland
    Mar 24 at 23:58














2












2








2







There is a way to distinguish forms using



<input type="submit" name="form" value="form1">



to send data, in that way you can read $_POST['form'] value and check what form it is



If you want to send data without form you can use ajax with Javascript.






share|improve this answer















There is a way to distinguish forms using



<input type="submit" name="form" value="form1">



to send data, in that way you can read $_POST['form'] value and check what form it is



If you want to send data without form you can use ajax with Javascript.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 25 at 1:40









CertainPerformance

112k1673102




112k1673102










answered Mar 24 at 22:26









pavelberepavelbere

595216




595216












  • "If you want to send data without form you can use ajax with javascript" Yes but you would still need a form with inputs to ask information.

    – Raymond Nijland
    Mar 24 at 22:31






  • 1





    I mean, you can use input without <form> and without standard form methods

    – pavelbere
    Mar 24 at 22:49











  • "I mean, you can use input without <form> and without standard form methods" that is invalid html, and you will have to ask yourself how browsers will handle that case and styling with css and javascript handling most likely it will work because most browsers are designed to display invalid html or fix broken/invalid html

    – Raymond Nijland
    Mar 24 at 22:50












  • @RaymondNijland - is it your intention to claim that the <form> element is the only one that accepts "phrasing content"? If this is not the case, your assertion that the html resultant from pavelbere's suggestion would be invalid appears incorrect. As stated at MDN, any element permitted to accept phrasing content can legally be the parent of an <input> element. Forms are no longer a requirement. ;) Buttons too, need only be parented by something capable of holding "prasing content"

    – enhzflep
    Mar 24 at 23:49











  • yes that direction i was going @enhzflep well then it seams that W3C HTML 5 specs have loosed up that, because it was first required you placed the input tag in a form tag before it was valid html, iam pretty sure of that.

    – Raymond Nijland
    Mar 24 at 23:58


















  • "If you want to send data without form you can use ajax with javascript" Yes but you would still need a form with inputs to ask information.

    – Raymond Nijland
    Mar 24 at 22:31






  • 1





    I mean, you can use input without <form> and without standard form methods

    – pavelbere
    Mar 24 at 22:49











  • "I mean, you can use input without <form> and without standard form methods" that is invalid html, and you will have to ask yourself how browsers will handle that case and styling with css and javascript handling most likely it will work because most browsers are designed to display invalid html or fix broken/invalid html

    – Raymond Nijland
    Mar 24 at 22:50












  • @RaymondNijland - is it your intention to claim that the <form> element is the only one that accepts "phrasing content"? If this is not the case, your assertion that the html resultant from pavelbere's suggestion would be invalid appears incorrect. As stated at MDN, any element permitted to accept phrasing content can legally be the parent of an <input> element. Forms are no longer a requirement. ;) Buttons too, need only be parented by something capable of holding "prasing content"

    – enhzflep
    Mar 24 at 23:49











  • yes that direction i was going @enhzflep well then it seams that W3C HTML 5 specs have loosed up that, because it was first required you placed the input tag in a form tag before it was valid html, iam pretty sure of that.

    – Raymond Nijland
    Mar 24 at 23:58

















"If you want to send data without form you can use ajax with javascript" Yes but you would still need a form with inputs to ask information.

– Raymond Nijland
Mar 24 at 22:31





"If you want to send data without form you can use ajax with javascript" Yes but you would still need a form with inputs to ask information.

– Raymond Nijland
Mar 24 at 22:31




1




1





I mean, you can use input without <form> and without standard form methods

– pavelbere
Mar 24 at 22:49





I mean, you can use input without <form> and without standard form methods

– pavelbere
Mar 24 at 22:49













"I mean, you can use input without <form> and without standard form methods" that is invalid html, and you will have to ask yourself how browsers will handle that case and styling with css and javascript handling most likely it will work because most browsers are designed to display invalid html or fix broken/invalid html

– Raymond Nijland
Mar 24 at 22:50






"I mean, you can use input without <form> and without standard form methods" that is invalid html, and you will have to ask yourself how browsers will handle that case and styling with css and javascript handling most likely it will work because most browsers are designed to display invalid html or fix broken/invalid html

– Raymond Nijland
Mar 24 at 22:50














@RaymondNijland - is it your intention to claim that the <form> element is the only one that accepts "phrasing content"? If this is not the case, your assertion that the html resultant from pavelbere's suggestion would be invalid appears incorrect. As stated at MDN, any element permitted to accept phrasing content can legally be the parent of an <input> element. Forms are no longer a requirement. ;) Buttons too, need only be parented by something capable of holding "prasing content"

– enhzflep
Mar 24 at 23:49





@RaymondNijland - is it your intention to claim that the <form> element is the only one that accepts "phrasing content"? If this is not the case, your assertion that the html resultant from pavelbere's suggestion would be invalid appears incorrect. As stated at MDN, any element permitted to accept phrasing content can legally be the parent of an <input> element. Forms are no longer a requirement. ;) Buttons too, need only be parented by something capable of holding "prasing content"

– enhzflep
Mar 24 at 23:49













yes that direction i was going @enhzflep well then it seams that W3C HTML 5 specs have loosed up that, because it was first required you placed the input tag in a form tag before it was valid html, iam pretty sure of that.

– Raymond Nijland
Mar 24 at 23:58






yes that direction i was going @enhzflep well then it seams that W3C HTML 5 specs have loosed up that, because it was first required you placed the input tag in a form tag before it was valid html, iam pretty sure of that.

– Raymond Nijland
Mar 24 at 23:58




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329082%2fhow-to-pass-a-post-variable-without-a-form%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript