I wanna send some variables to another server with post method. I made a code and it worked on my localhost. But I cannot made it work for another site.
<form name='myform' action='#' method='POST'>
<input type='hidden' name='intnumber' value='15'>
<a id='Link' onclick='document.myform.submit()' href='#'>Go!</a>
</form>
I wanna get keywords to my site automaticly. I use Ubersuggest site manual but it takes long time add keywords manually. So, I wanna send ubersuggest.org post form to search keywords and take the keywords with php bot. I prepared a code for search part, it is not working:
<form name='uberform' action='http://www.ubersuggest.org/' method='POST'>
<input type='hidden' name='query' value='game'>
<input type='hidden' name='language' value='English/UK'>
<input type='hidden' name='source' value='web'>
<a id='Link' onclick='document.uberform.submit()' href='#'>Go!</a>
</form>
Please help me for correcting this code.
NOTE: I want to use this site just personally, i will not make any profit. And I dont want attack etc. to this site, cos' i love it and i use it!
Try using http://php.net/manual/en/book.curl.php. Post to other domains is not allowed.
Related
I still in training,
But i stuck in this problem.
// we need this password in 2 form POST
<input style='text' name='password' />
<form action='delete.php' method='POST'>
... // i need password to be here
<input type='submit' name='delete' value='Del' />
</form>
<form action='edit.php' method='POST'>
... // and i need password to be here too
<input type='submit' name='edit' value='Edit' />
</form>
My menthor want to do this using 2 form but I need the input password outside this 2 form.
Are there any way to do this without using script?
I can do this with 1 form and action.php that include 2 php file(edit.php and delete.php)
But he said that it is waste.
Can someone help? I already checking using search engine and found nothing.
Maybe your mentor just testing you on how you solve the situation.. As far as i know... you cant pass value of a textbox upon submit without putting the textbox inside a form.. I just wonder why javascript is forbidden.. Well anyway I suggest you to use 1 form and 1 page for the action and in the action make an if statement to separate you delete and edit method.. maybe in that case it is not waste.. It's just only a suggestion..
I have a form on a page that is used to "Add/Edit a Location". Here is my form:
<form id='locationEditForm' name='locationEditForm'>
<table width='50%'>
<tr><td colspan='2'><hr></td></tr>
<tr><td colspan='2'><button type='submit' name='save' id='save'>Lookup Location By ID: </button>
<input type='text' size='10' name='locationToEdit'><br/><br/></td></tr>
<tr><td>Name:</td><td><input type='text' name='locationName'/></td></tr>
<tr><td>URL:</td><td><input type='text' name='locationURL'/></td></tr>
<tr><td>Coordinates:</td><td><input type='text' name='locationCoords'/></td></tr>
<tr><td>Address:</td><td><textarea name='locationAddress' rows='4' cols='40'></textarea></td></tr>
<tr><td>Phone:</td><td><input type='text' name='locationPhone'/></td></tr>
<tr><td>Hours:</td><td><textarea name='locationHours' rows='3' cols='40' wrap='soft'/></textarea></td></tr>
<tr><td colspan='2'><button type='submit' name='save' id='save'>Save Changes</button>
<button type='button' class="cancel">Cancel</button></td></tr>
</table>
</form>
I've wrapped the form elements in a table just for the sake of keeping the input boxes aligned for now in a "quick and dirty" sort of way.
Anyway, As you can see, I have a button and input area for the user to "lookup" an existing location by id. This is so that an existing location can be edited. I understand how to make that button 'submit' to my php code and to then lookup the location in the database, but my question is this -- is it possible to lookup the location in a MySQL database and load the information into the existing form without causing the page to reload as it normally would when I post the form?
Ideally, I imagine the data for an existing location just "popping" into the form without the entire page reloading. How would I go about doing something like this?
Thanks a ton!
The technique you're looking for is commonly referred to as Ajax. In your case, you'd want to submit an XMLHttpRequest() to a different PHP script which returns data you can use. Either HTML to insert into your form, or JSON data which you parse and use to update field values would be good choices.
There are lots of resources out there on how to make a PHP/MySQL endpoint for an Ajax request. These search terms should get you started. Good luck!
Indeed it is, you have to use javascript though. I would advise you to take a look at Jquery. And it's $.ajax and $.post functions.
In PHP, i want to open more that one window and each one of them need to recieve different post data.
i know how to redirect a page via header location + Get DATA, but i really need to be able to send POST data.
EDIT:
Graph
|-Page with post 1
Main --|-Page with post 2
|-Page with post 3
so basically 1 page goes and open 3 pages with different post data on each. must be done server Side.
why not use three forms? ;-) Code tested, works.
<form method='post' action='http://<sever>/post1.php' id='action_frm1' name="action_frm1" target="_blank">
<input type='hidden' name='param1' value='hello'/>
<input type='hidden' name='param2' value='world'/>
</form>
<form method='post' action='http://<sever>/post2.php' id='action_frm2' name="action_frm2" target="_blank">
<input type='hidden' name='param1' value='hello2'/>
<input type='hidden' name='param2' value='world2'/>
</form>
<form method='post' action='http://<sever>/post3.php' id='action_frm3' name="action_frm3" target="_blank">
<input type='hidden' name='param1' value='hello3'/>
<input type='hidden' name='param2' value='world3'/>
</form>
<script type='text/javascript'>
function makePostRedirect() {
document.getElementById('action_frm1').submit();
document.getElementById('action_frm2').submit();
document.getElementById('action_frm3').submit();
}
makePostRedirect()
</script>
Of course, if you want post data via serverside usefull link will be this: http://noobflash.com/server-side-post-with-php/
you may use the following trick:
<form method='post' action='action.php' id='action_frm'>
<input type='hidden' name='param1' value='hello'/>
<input type='hidden' name='param2' value='world'/>
</form>
<script type='text/javascript'>
function makePostRedirect() {
document.getElementById('action_frm').submit();
}
</script>
You will need to do a workaround by calling window.open to some stub PHP pages that can then use some JavaScript to call a form post. What your asking can not really be done in PHP because PHP is server side and not front end. Your looking for a much more JavaScript reliant solution.
You can do a single POST to a new window by putting a target="_new" on the <form> element. It won't validate, but it will open ONE new window and submit the form data via that window.
For multiple windows, you'll have to hack together some JS to open the multiple windows, insert a form with a copy of the data you want to have posted in that window, then trigger the posts individually.
how about this:
Original page ---opens---> page 1 ---opens---> page 2 ---opens---> page 3
Each page passes the data for the remaining pages. Search for javascript pop-up code that works and runs on page open.
I have a bunch of Aweber forms with just a name and email field on my site. The forms are getting a lot of spam registrations. Is there a way that I can prevent these bots from filling my forms?
<form method='post' action='http://www.aweber.com/scripts/addlead.pl'>
<div style='display:none;'>
<input type='hidden' name='meta_web_form_id' value='-----' />
<input type='hidden' name='meta_split_id' value='' />
<input type='hidden' name='listname' value='-----' />
<input type='hidden' name='redirect' value='-----' />
<input type='hidden' name='meta_adtracking' value='-----' />
<input type='hidden' name='meta_message' value='1' />
<input type='hidden' name='meta_required' value='name,email' />
</div>
<ul class='vMenuForm'>
<li class='lname'>Name(<span class='red'>*</span>):</li>
<li class='name'><input type='text' name='name' value=''/></li>
<li class='lemail'>Email(<span class='red'>*</span>):</li>
<li class='email'><input type='text' name='email' value=''/></li>
<li class='submit'><input class='button' type='submit' name='submit' value=''/></li>
</ul>
<div style='display: none;'><img src='http://forms.aweber.com/form/displays.htm?id=HKwMHMzMTCyM' alt='' /></div>
</form>
This is one of the forms as it exists now. Any ideas?
I would actually put a couple of "honeypot" fields in as type="hidden", such as "last_name", "first_name", as spam bots will usually fill those in. Then, server-side, check to see if those 2 fields are filled in; if so, log the attempt for tracking and stop processing the data. Captchas help some as well, though not as much these days.
Use a captcha system like reCAPTCHA (by Google) or some kind of special "only-humans-can-answer" type thing, like "What day is it today?"
They also have very nice PHP plugins and examples for you. It's very simple, just use it like this:
require_once('recaptchalib.php');
$publickey = "public_key";
echo recaptcha_get_html($publickey);
You could try a few "honeypot" techniques (fields that users can't fill in, usually because are hidden, but fields that bots will normally true to fill in), but bots are learning to counter them these days by detecting if you've set fields the honeypot fields to hidden, both via. CSS and Javscript, so this won't be a guarantee that all bots will be stopped.
I would create the form dynamically using javascript. This should keep the simple Bots from posting your form. Though this solution has drawbacks like your users must have javascript enabled.
Is it possible in php to include a forms value into the action redirection?
For example:
<form method='POST' name='Select' action='customer.php?CID=xxxxx'>
<input type=text width='5' name='searchVal' />
where xxxxx is the value entered into the form.
I've tried a number of different ways and I'm just not figuring it out! (Still sort of new to php) Any help would be appreciated.
It was looking like I would have to use $_POST and $_GET. A little more information might be in order... customer.php displays a list of customers in order by ID, name, etc. The user currently clicks on the customer ID that they want to display the details for. I'm trying to add a box where they can just enter the customer number to get to the details quickly, but I still want to have the listing displayed. From what it is sounding like, I will have to do this as two separate programs...is that true?
How about this:
<form method='POST' name='Select' action='customer.php'>
<input type='hidden' value='xxxxx' name='CID' />
<input type=text width='5' name='searchVal' />
...
</form>
You are free to add as much hidden values as needed.
Note, that you can even use PHP-like array notation_
<input type='hidden' value='xxxxx' name='CID[1]' />
<input type='hidden' value='yyyyy' name='CID[2]' />
At the PHP-side, access those values using this syntax:
$_POST[ 'CID' ][ 1 ]
$_POST[ 'CID' ][ 2 ]
UPDATE-1
Ah, you want to use a user-entered values to the Action URL just before the form gets submitted?
In this case you need to use JavaScript. Access the DOM to change the Action URL.
But let me ask, why you need to post a form value additionally as a parameter of the Action URL?
UPDATE-2
You wrote: 'From what it is sounding like, I will have to do this as two separate programs...is that true?'
No, actually not. You can still use one customer.php which checks at its beginning, if it was called using a linked customer in the table element or a searched customer in the search field.
In other words: You don't need to prepare two scripts, but two forms for two purposes which call the same script customer.php.
You can include the required value in a hidden field in your form:
<input type="hidden" name="CID" value="xxxxx" />
The reason this is required is that you are submitting the form to your server via POST, but appending parameters to the URL requires submission via the GET method.
Not without a post to the server. The value in the form is filled in client-side, so it has to return to the server before you can add it to the action. (at least, if you want to use php).
You can either
add it after posting (might not be usefull)
use javascript
just not use the GET CID, but get it out of the POST in your customer.php script.
I got it finally! It's actually very simple!
In the body of the code I put this:
<form action='#_SELF' method='GET' name='Projected'>
<input type=text size=5 name='CID' value='' title='Enter Customer number to display' />
<a href='#' onclick='document.Projected.submit();' title='Enter Customer number to display'>Go</a>
And at the top of the code I just do a:
if (!isset($_GET['CID'])) { ...
It works exactly the way I wanted it to!
Thanks everyone for the help! I appreciate it! (And I'm learning more and more about PHP everyday!)
Im pretty sure you cant do that unfortunately