I want to get URL from HTML form action. How can I get this in PHP? The form tag like
<form method="post" action="my.aspx? id="aspnetForm" enctype="multipart/form-data">
</form>
I want to get URL from HTML form action. How can I get this in PHP? The form tag like
<form method="post" action="my.aspx? id="aspnetForm" enctype="multipart/form-data">
</form>
You can try to load the HTML with DOM and then extract the information using xpath:
// create a DOM document object and load your html
$doc = new DOMDocument();
$doc->loadHtml($yourHtml);
// create an Xpath selector for the document
$selector = new DOMXpath($doc);
// the following query will return all <form> elements
// you may refine it
$result = $selector->query('//form');
// get the first item (to keep the example simple)
$form = $result->item(0);
// get the value of the action attribute
$url = $form->getAttribute('action');