Click here to Skip to main content
15,607,737 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to write a php function which gets a string, goes to the url I want, puts the string in to a text field in that url, submits it and returns the text shown after submitting. I'm lost guys, help me.

What I have tried:

$html= curl_init('');
Updated 28-Jun-18 22:54pm
Richard MacCutchan 28-Jun-18 12:57pm    
Do you mean you want to inject a script into someone else's website? Or are you asking about webscraping? If the latter you can Google for samples.

1 solution

It sounds like you're automatically trying to fill a form on a website, submitting it and then showing the result. I would check the website's source to find the relevant field and see what it does on submitting.

It will look something like this:

<form method="get" action="/action.php">
  <input type="text" name="field1">

The form's method ("get") identifies if you should do a POST or GET request.
The form's action ("/action.php") will give you the URL to request.
The input's name ("field1") will be the name of the parameter.
Share this answer
Member 13891176 29-Jun-18 6:11am    
Thank you very much for answering.
I found the part which contains these parameters, but I still don't know how to set/get them. how can I refer to them?
[no name] 29-Jun-18 6:51am    
In my example, the URL would be /action.php?field1=foo if the user entered "foo".
For an example with POST have a look here:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900