How can I send a post form without click submit button? - php

For example below code, I have to click on submit button to go to the destination post page, but I want to go to the destination page without click on the submit button, and I want to go to the destination page with click on the button in my telegram bot an run my code page.
<html>
<body>
<form action="?????????" method="post" target="_blank">
type: <input type="text" name="type" value="111" ><br>
amount: <input type="text" name="amount"value="1000"><br>
cellphone: <input type="text" name="cellphone"value="2222"><br>
email: <input type="text" name="email"value="111#gmail.com"><br>
webserviceId: <input type="text" name="webserviceId"value="34433"><br>
redirectUrl: <input type="text" name="redirectUrl"value="w2323.php"><br>
issuer: <input type="text" name="issuer"value="ssdsd"><br>
redirectToPage: <input type="text" name="redirectToPage"value="True"><br>
scriptVersion: <input type="text" name="scriptVersion"value="Script"><br>
firstOutputType: <input type="text" name="firstOutputType"value="get"><br>
secondOutputType: <input type="text" name="secondOutputType"value="get"><br>
<input type="submit" value="submit">
</form>
</body>
</html>

Add an id to the form, then bind a function on a button. Although your question is a bit unclear on what you want exactly
<form id='someid'>
type: <input type="text" name="type" value="111" ><br>
amount: <input type="text" name="amount" value="1000"><br>
cellphone: <input type="text" name="cellphone" value="2222"><br>
email: <input type="text" name="email" value="111#gmail.com"><br>
webserviceId: <input type="text" name="webserviceId" value="34433"><br>
redirectUrl: <input type="text" name="redirectUrl" value="w2323.php"><br>
issuer: <input type="text" name="issuer" value="ssdsd"><br>
redirectToPage: <input type="text" name="redirectToPage" value="True"><br>
scriptVersion: <input type="text" name="scriptVersion" value="Script"><br>
firstOutputType: <input type="text" name="firstOutputType" value="get"><br>
secondOutputType: <input type="text" name="secondOutputType" value="get"><br>
<button onclick="myFunc()">
</form>
JS
function myFunc() {
document.getElementById("someid").submit();
}

Related

How i can send few values from inputs with auto increment?

I have block:
<div>
<input type="text" name="account[surname][]">
<input type="text" name="account[address][]">
<input type="text" name="account[phone][]">
...
<input type="number" name="account[number][][1]">
<input type="number" name="account[number][][2]">
<input type="number" name="account[number][][3]">
</div>
After submit i get:
{"id":{"13":""},"surname":{"13":"Mike"},"number":{"13":{"1":"623"},"14":{"2":"432"},"15":{"3":"542"}}}
But i need:
{"id":{"13":""},"surname":{"13":"Mike"},"number":{"13":{"1":"623","2":"432","3":"542"}}}
Id - Auto Increment.
Every "account[number][]" create new array. How can I put this data into an one array?
This form is added dynamically (clone).
For static form work this code, but i need dinamic:
<form>
<input type="text" name="account[surname][10]">
<input type="text" name="account[address][10]">
<input type="text" name="account[phone][10]">
...
<input type="number" name="account[number][10][1]">
<input type="number" name="account[number][10][2]">
<input type="number" name="account[number][10][3]">
<button type="submit">Send</button>
</form>

Html form works fine on computer but submit button doesnt work on Mobile Phones

Here's a simple html form code using php and POST method. It works fine on Computers but the submit button doesn't work on Mobile phones. It doesn't click when we touch it.
<form action="contact2.php" method="POST">
Your name:<br>
<input name="name" size="30" type="text" /><br> Your mobile no:<br>
<input name="phone" size="15" type="text" /><br> Your email:<br>
<input name="email" size="30" type="text" /><br> Your message:<br>
<textarea name="msg" rows="7" cols="30">
</textarea><br />
<input class="formsubmit" type="submit" value="Send Email" />
</form>
Try to use button tag instead of input
<button class="formsubmit" type="submit">Send Email</button>

How to retrieve address in custom html form and send to paypal?

So i have written an html order form with 5 fields(company name, firstname, lastname, email and address.) http://www.topchoicedata.com/175.php#175
When the user clicks submit, it will take them to a paypal payment page. I used a cool script called paypal payment form from hotdreamweaver script, which converts any form into a paypal form. This creates the action called "PPPaymentForm/PPPaymentForm.php" PHP can be found under this link http://www.cedarpublishing.com/phpcode.txt
The problem i am having is that paypal is not able to retrieve the address and when the person buys the product from me, it says from the buyer end(me) that no shipping address was provided and that i have to confirm with the buyer. So i need a way so that paypal grabs that address field when they submit the order form, and even the first and last names if possible.
I read up on paypal variables, but i am unsure on how to embed them. Below is my form.
<form action="PPPaymentForm/PPPaymentForm.php" method="post" name="topchoiceform" id="topchoiceform">
<input placeholder="Company Name" type="text" name="companyname" required>
<input placeholder="First Name" type="text" name="firstname" required>
<input placeholder="Last Name" type="text" name="lastname" required>
<input placeholder="Email" type="email" name="email" id="email" required>
<input placeholder="Address" type="text" name="address" required>
<input name="shipping" class="shipping" type="checkbox" id="shipping" value="19.99"/>
<label class="shippingcheck">19.99(Optional Shipping, will be added to total if chosen)</label>
<br>
<br>
<button name="submit" type="submit" id="submit">Pay Now</button>
<input type="hidden" name="hdwtablename" id="hdwtablename" value="1">
<input type="hidden" name="hdwppproductname" id="hdwppproductname" value="Basic Plan $175">
<input type="hidden" name="hdwppamount" id="hdwppamount" value="175">
<input type="hidden" name="hdwppcurrency" id="hdwppcurrency" value="USD">
<input type="hidden" name="hdwpplanguage" id="hdwpplanguage" value="en_US">
<input type="hidden" name="hdwok" id="hdwok" value="http://">
<input type="hidden" name="hdwemail" id="hdwemail" value="mauriceflopez+gmail.com">
<input type="hidden" name="hdwnook" id="hdwnook" value="http://">
<input type="hidden" name="hdwactivation_email" id="hdwactivation_email" value="none">
<input type="hidden" name="plan" id="plan" value="$175">
<input type="hidden" name="shippingchoosen" id="shippingchoosen" value="">
<input type="hidden" name="shippingnumber" id="shippingnumber" value="">
</form>

I need a form not to clear the fields during a submit for test mode

I'm writing a php form that has a button to test the database connection before proceeding to the next step. The only problem is that running the test, clears the fields. I can put onsubmit="return false" at the top of the form, but then the test works fine, but I can't submit the form for its real purpose then. I'm guessing this could be fixed with javascript, but I'm a total noob there and I'm wondering if there is a PHP/HTML way to accomplish this.
Here's the form. The test button runs a test pdo connection and gives feedback and the "Next Step >>" button writes the configuration to a file and goes on to the next step.
<H2>Please fill in your database credentials</H2>
<form class="form" action="" onsubmit="return false" method="post">
<label for="dbh">Database Host
<input class="form-control" type="text" name="dbh" value=""></label>
<br><br>
<label for="dbu">Database User
<input class="form-control" type="text" name="dbu" value=""></label>
<br><br>
<label for="dbp">Database Password
<input class="form-control" type="text" name="dbp" value=""></label>
<br><br>
<label for="dbn">Database Name
<input class="form-control" type="text" name="dbn" value=""></label>
<br><br>
<input class="btn btn-success" type="submit" name="test" value="Test Settings">
<input class="btn btn-primary" type="submit" name="submit" value="Next Step >>">
</form>
You need to write in $_POST vars in your inputs.
<label for="dbh">Database Host
<input class="form-control" type="text" name="dbh" value="<? if ($_POST['dbh']){ print $_POST['dbh']; } ?>"></label><br><br>
<label for="dbu">Database User
<input class="form-control" type="text" name="dbu" value="<? if ($_POST['dbu']){ print $_POST['dbu']; } ?>"></label><br><br>
<label for="dbp">Database Password
<input class="form-control" type="text" name="dbp" value="<? if ($_POST['dbp']){ print $_POST['dbp']; } ?>"></label><br><br>
<label for="dbn">Database Name
<input class="form-control" type="text" name="dbn" value="<? if ($_POST['dbn']){ print $_POST['dbn']; } ?>"></label><br><br>

Append variables to url after form submit

I have this Landing Page that I need to pre-populate with form values after it is submitted. Essentially in the end I have to make the url look like this...
http://example.com/r.php?sid=xx&pub=xxxxx&c1=&c2=&c3=&append=1&firstname=Test&lastname=Smith&address=2211+Commerce+St.&city=Dallas&state=TX&zipcode=75080&email=test#test.com
What I currently have now for the form is...
<form name="regForm" method="get" action="http://example.com/r.php?sid=xx&pub=xxxx&c1=&c2=&c3=&append=1">
<input id="firstname" class="text" type="text" name="firstname"/><br>
<input id="lastname" class="text" type="text" name="lastname" /><br>
<input id="email" class="text" type="text" name="email" /><br>
<input id="address" class="text" type="text" /><br>
<input id="city" class="text" type="text"/><br>
<input id="zipcode" class="text" type="text" maxlength="5" name="zipcode" /><br>
<input type="submit" value="Send Me My FREE List" id="submitBtn2"/>
</form>
How do i create that URL above after the form is submitted? I have been racking my brain all day on this and can't figure it out, i feel like im close.
thanks for the help!
Include the extra parameters as hidden form fields instead of inline query parameters:
<form name="regForm" method="get" action="http://example.com/r.php">
<input type="hidden" name="sid" value="xx" />
<input type="hidden" name="pub" value="xxxx" />
<input type="hidden" name="c1" value="" />
<input type="hidden" name="c2" value="" />
<input type="hidden" name="c3" value="" />
<input type="hidden" name="append" value="1" />
<input id="firstname" class="text" type="text" name="firstname"/><br>
<input id="lastname" class="text" type="text" name="lastname" /><br>
<input id="email" class="text" type="text" name="email" /><br>
<input id="address" class="text" type="text" /><br>
<input id="city" class="text" type="text"/><br>
<input id="zipcode" class="text" type="text" maxlength="5" name="zipcode" /><br>
<input type="submit" value="Send Me My FREE List" id="submitBtn2"/>
</form>
The problem is the input field get variables are causing your url get variables to be truncated, put all your url parameters as hidden values.
<input id="pub" type="hidden" name="pub" value=""/>
<input id="sid" type="hidden" name="sid" value=""/>
I'm assuming that you like the URL that it generates except that you're missing the sid, pub, c1, c2, c3, and append variables. If so, just make hidden inputs like this:
<form id="regForm" ...>
<input id="sid" name="sid" value="" type="hidden" />
<input id="pub" name="pub" value="" type="hidden" />
...
</form>
If you know the values while you're creating the form, then you can do it on the server side. If you don't, then assuming you're using jQuery, you will have to do something like this:
$(function() {
$('#regForm').submit(function () {
$('#sid').val('myNewSidValue');
$('#pub').val('myNewPubValue');
...
});
});

Categories