简体   繁体   中英

Form submit data to database and to url

I need to submit a form to a url for processing, and also insert the form fields to a database. The form is standard HTML, and the action is currently set to :

<FORM name = "HTML_FORM" METHOD=POST ACTION="https://urlhere/MRcgi/ProcessIncomingForms.pl">

My first thought was to change the action to a custom php page,which would

  1. Send the data to the above script
  2. perform the insert into DB.

But - and this is my question- not sure if they can be done and how to do- in sequence??

Note: I dont have access to the ProcessIncomingForms.pl script, and I dont think this will matter but, the form fields don't match the database fields, so I will also have to do reassignments before I can submit into the database. Ex:

$help_user = $_POST['username'];
$help_dept = $_POST['help_dept'];

Change the action as you suggested, then on the new php page insert into the db as normal then create a form and submit it for the user:

<form action='https://urlhere/MRcgi/ProcessIncomingForms.pl' method='post' name='frm'>
<?php
foreach ($_POST as $a => $b) {
echo "<input type='hidden' name='".htmlentities($a)."' value='".htmlentities($b)."'>";
}
?>
</form>
<script language="JavaScript">
document.frm.submit();
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM