How to submit a form to destination url as destination site - php

I need to submit a form with action is:"http://www.destination.com/hotelbooking" as "http://www.destination.com" but I do not own that site.
My site is http://www.mysite.com, after the submitting, url in my browser is "http://www.mysite.com/bookingstatus" instead of "http://www.destination.com/bookingstatus".
I guess that the site force me to submit my form from a browser because if I use curl, it doesn't worked(but I need to do that with php).(*My edit)
How can I solve this problem?
This is my form:
<form name="booking" method="post" action="https://www.destination.com/hotelbooking" >
<input name="roomsnum" type="text">
<input name="adultnum" type="text">
<input name="childnum" type="text">
<input name="infannum" type="text">
<input name="roomsize" type="text">
<input name="submit" type="submit" value="booking">
</form>
Thanks a lot

Related

2 Form Submits interfering with each other

I have a PHP script where I upload a *.txt file and I use the information inside that *.txt file to do some things.
The form for uploading this text file:
<form method="post" action="index.php" enctype="multipart/form-data">
<input class="file-choice" name="file" type="file" />
<input class="upload-button" type="submit" value="Upload Bestand" name="start" />
</form>
After I worked with this file I want to give the visitor a choice to change some things, with their own input.
The form for the user input:
<form method="post">
<div class="input-block">
<b>Rechts naar links:</b> <br>
<input type="radio" name="horizontaal" value="rl-aan">Aan
<input type="radio" name="horizontaal" value="rl-uit">Uit<br>
</div>
<div class="input-block">
<b>Verticaal:</b> <br>
<input type="radio" name="verticaal" value="ver-aan">Aan
<input type="radio" name="verticaal" value="ver-uit">Uit<br>
</div>
<div class="input-block">
<b>Diagonaal:</b> <br>
<input type="radio" name="diagonaal" value="dia-aan">Aan
<input type="radio" name="diagonaal" value="dia-uit">Uit<br>
</div>
<input type="submit" name="test" />
</form>
My problem is when I press the submit button of either the file upload or user input the other form is retested. So for example if I press the submit for the user input, the file that I uploaded before is gone.
I tried changing the method from POST to GET and I've tried to give both the submits the same name but both did not work.
Any suggestions?
I figured it out.
I had to work with sesions to save the needed variables from reading the file and add the name of the user input submit to all the scripts except the read script from the file.
Give different form id and submit button id .

Form data not staying consistent, resetting after submit

This is hard to explain so bear with me.
I'm building a page that consists of multiple forms that are all submitted with one submit button at the bottom like so:
<form action="" method="post">
<input type="text" name="name1" value="<?$variable1;?>" placeholder="Type here...">
<form action="" method="post">
<input type="text" name="name2" value="<?$variable2;?>" placeholder="Type here...">
<form action="" method="post">
<input type="text" name="name3" value="<?$variable3;?>" placeholder="Type here...">
<form action="" method="post">
<input type="text" name="name4" value="<?$variable4;?>" placeholder="Type here...">
<input type="submit" name="submit" value="Submit">
</form>
Each of these forms asks the user for data, which then echos to a text box so that they can copy/paste the output.
Now, suppose the user fills out the data for one of these forms only and clicks on the submit button. Naturally, the data they entered would go to the text box. What I need however is that when the user then decides to fill out the rest of the forms, the data that was originally echoed is still in the text box, preferrably as well as the answer they put in the form (however not essential).
What I'm finding at the moment is that the form resets after clicking submit, so even though the user has submitted one part of the form, when they go to fill out the rest and click submit again, only the other 3 are echoed and the first one is omitted.
I hope this makes sense. Any idea on how one would go about this?
EDIT: Nearly got it with the following:
if (isset($_POST['submit'])) {
if (isset($_SESSION['test1'])) {
$_SESSION['test1']=$_SESSION['test1'];
}
else {
$_SESSION['test1'] = $_POST['test1'];
}
}
However the variable now doesn't change when we enter something new into the form field...
<form action="" method="post">
<input type="text" name="name1" value="<?$variable1;?>" placeholder="Type here...">
<input type="text" name="name2" value="<?$variable2;?>" placeholder="Type here...">
<input type="text" name="name3" value="<?$variable3;?>" placeholder="Type here...">
<input type="text" name="name4" value="<?$variable4;?>" placeholder="Type here...">
<input type="submit" name="submit" value="Submit">
</form>
Call only once. One submit button is for 1 form. Please try this. It should work
You need <?= $variable1; ?> etc. Otherwise it doesn't output anything.

data forward to search page instead of form action page

I have a newsletter form which forward the data to newsletter.php but search.php page open when click on submit my form html code is:
<form action="../newsletter.php" method="post">
<input type="text" class="field" placeholder="Your Name" name="name" />
<input type="text" class="field" placeholder="Email" name="email" />
<div class="form-buttons"><input type="submit" value="Submit" class="submit-btn" />
</div> </form>
You can check if your entire file don't have another declaration. Maybe you have another form opened, and this newsletter form is inside of the other one. This will always submit the parent form.
Look for a
Check if there is a redirect to search.php on your newsletter.php page.

PHP Form to redirect with form results

I have a form that when they submit it, it stores the info in the database. I need to be able to get the form data to come up on redirect page.
It does not need to fetch the database as I would love to do this PHP style. So lets say they enter there name and city. When they click submit it redirects them to a thank-you page with the results from the form on that page.
In a form, you have each element have a name, lets say name="username", in the php, yould get the value of this as either a get, or a post response, depending on the method of the form.
HTML Form
<form action="process.php" method="get">
<input name="username" type="text"></input>
<input type="submit" value="Submit"></input>
</form>
or
<form action="process.php" method="post">
<input name="username" type="text"></input>
<input type="submit" value="Submit"></input>
</form>
process.php
$someusername = $_GET['username'];
$someusername = $_POST['username'];
Form page:
<form action="thanks.php" method="post"><input type="text" name="myname" placeholder="Name" /><input type="text" name="mycity" placeholder="City" /><input type="submit" value="submit"></form>
PHP Page
print "Thanks, ".$_POST['myname']." who lives in ".$_POST['mycity']."!";

2 Forms in a page, Get the Value from the other form

I have 2 HTML form in a page
<form action="my-page.php" method="post" id="savedata" name="savedata">
<input class="text" name="myname" value="" type="text" />
<input class="text" name="myaddress" value="" type="text" />
<input type="submit" value="Save" />
</form>
<form action="my-page.php" method="post" id="previewdata" name="previewdata">
<input type="submit" value="Preview" />
</form>
The first one [savedata] will save the data to MySQL after clicking the [Save Button]
The second one [previewdata] will preview (means will just show in the page using HTML) the data once the [Preview Button] was clicked
How can the 2nd form get the data from the 1st form?
As an alternative to using 2 different forms you could have a single form with 2 submit buttons:
<form action="my-page.php" method="post">
<input class="text" name="myname" value="" type="text" />
<button type="submit" name="action" value="save">Save</button>
<button type="submit" name="action" value="preview">Preview</button>
</form>
Now inside your server side script look for $_POST["action"] and act accordingly.
Also in HTML5 there's the formaction attribute that could be specified on a submit button to invoke a different server side script.

Categories