PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
shaks786
Forum Newbie
Posts: 7 Joined: Fri Jul 17, 2009 1:23 pm
Post
by shaks786 » Fri Jul 17, 2009 1:26 pm
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
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Jul 17, 2009 1:33 pm
You can use the $_POST array.
shaks786
Forum Newbie
Posts: 7 Joined: Fri Jul 17, 2009 1:23 pm
Post
by shaks786 » Fri Jul 17, 2009 1:46 pm
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
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Jul 17, 2009 2:35 pm
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.
shaks786
Forum Newbie
Posts: 7 Joined: Fri Jul 17, 2009 1:23 pm
Post
by shaks786 » Fri Jul 17, 2009 4:36 pm
that does not seem to work,
i tried tweaking it, but got no luck
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Jul 17, 2009 5:42 pm
Bollocks. My attempt at "quick coding" didn't pay off.
You'll need to put method="post" in the form tag.
shaks786
Forum Newbie
Posts: 7 Joined: Fri Jul 17, 2009 1:23 pm
Post
by shaks786 » Fri Jul 17, 2009 5:50 pm
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
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Jul 17, 2009 6:20 pm
You need to replace $ch with your curl handle.
shaks786
Forum Newbie
Posts: 7 Joined: Fri Jul 17, 2009 1:23 pm
Post
by shaks786 » Fri Jul 17, 2009 6:27 pm
EDIT:
PROBLEM SOLVED
CODE DELETED
Last edited by
shaks786 on Sat Jul 18, 2009 6:57 am, edited 1 time in total.
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Jul 17, 2009 7:05 pm
You haven't got a curl handle at all!!
You need this
Somewhere above where you're setting all your curl args.
shaks786
Forum Newbie
Posts: 7 Joined: Fri Jul 17, 2009 1:23 pm
Post
by shaks786 » Sat Jul 18, 2009 4:07 am
Parse error: syntax error, unexpected T_STRING in /home/shaks786/public_html/avoidftp.php on line 9
shaks786
Forum Newbie
Posts: 7 Joined: Fri Jul 17, 2009 1:23 pm
Post
by shaks786 » Sat Jul 18, 2009 6:56 am
ok,
it does not matteer,
i've solved the problem now
Thanks for the help!