Page 1 of 1
PHP Form Help Please
Posted: Fri Jul 17, 2009 1:26 pm
by shaks786
Hey,
in my php code I have the following line:
Code: Select all
curl_setopt($ch, CURLOPT_URL,
'http://news.google.com/news?hl=en&topic=t&output=rss')
how can I create a form, where what the user enters in a particular field in a the form replaces the url in the code above.
Thank You
Re: PHP Form Help Please
Posted: Fri Jul 17, 2009 1:33 pm
by jackpf
You can use the $_POST array.
Re: PHP Form Help Please
Posted: Fri Jul 17, 2009 1:46 pm
by shaks786
im a noob at php.
i tried using the Post array
but i could not get it to work
can you post an example please?
Thank You
Re: PHP Form Help Please
Posted: Fri Jul 17, 2009 2:35 pm
by jackpf
Code: Select all
if($_SERVER['REQUEST_METHOD'] != 'POST')
echo '<form><input type="text" name="url" />';
else
curl_setopt($ch, CURLOPT_URL, $_POST['url']);
Something like that....that's a very simple example...but should get you going.
Re: PHP Form Help Please
Posted: Fri Jul 17, 2009 4:36 pm
by shaks786
that does not seem to work,
i tried tweaking it, but got no luck
Re: PHP Form Help Please
Posted: Fri Jul 17, 2009 5:42 pm
by jackpf
Bollocks. My attempt at "quick coding" didn't pay off.
You'll need to put method="post" in the form tag.
Re: PHP Form Help Please
Posted: Fri Jul 17, 2009 5:50 pm
by shaks786
the following error pops up:
Warning: curl_setopt(): supplied argument is not a valid cURL handle resource in /home/shaks786/public_html/avoidftp.php on line 10
Re: PHP Form Help Please
Posted: Fri Jul 17, 2009 6:20 pm
by jackpf
You need to replace $ch with your curl handle.
Re: PHP Form Help Please
Posted: Fri Jul 17, 2009 6:27 pm
by shaks786
EDIT:
PROBLEM SOLVED
CODE DELETED
Re: PHP Form Help Please
Posted: Fri Jul 17, 2009 7:05 pm
by jackpf
You haven't got a curl handle at all!!
You need this
Somewhere above where you're setting all your curl args.
Re: PHP Form Help Please
Posted: Sat Jul 18, 2009 4:07 am
by shaks786
Parse error: syntax error, unexpected T_STRING in /home/shaks786/public_html/avoidftp.php on line 9
Re: PHP Form Help Please
Posted: Sat Jul 18, 2009 6:56 am
by shaks786
ok,
it does not matteer,
i've solved the problem now
Thanks for the help!