PHP Form Help Please

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

Post Reply
shaks786
Forum Newbie
Posts: 7
Joined: Fri Jul 17, 2009 1:23 pm

PHP Form Help Please

Post 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
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP Form Help Please

Post by jackpf »

You can use the $_POST array.
shaks786
Forum Newbie
Posts: 7
Joined: Fri Jul 17, 2009 1:23 pm

Re: PHP Form Help Please

Post 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
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP Form Help Please

Post 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.
shaks786
Forum Newbie
Posts: 7
Joined: Fri Jul 17, 2009 1:23 pm

Re: PHP Form Help Please

Post by shaks786 »

that does not seem to work,
i tried tweaking it, but got no luck
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP Form Help Please

Post by jackpf »

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

Re: PHP Form Help Please

Post 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
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP Form Help Please

Post by jackpf »

You need to replace $ch with your curl handle.
shaks786
Forum Newbie
Posts: 7
Joined: Fri Jul 17, 2009 1:23 pm

Re: PHP Form Help Please

Post by shaks786 »

EDIT:
PROBLEM SOLVED
CODE DELETED
Last edited by shaks786 on Sat Jul 18, 2009 6:57 am, edited 1 time in total.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP Form Help Please

Post by jackpf »

You haven't got a curl handle at all!!

You need this

Code: Select all

$ch = curl_init();
Somewhere above where you're setting all your curl args.
shaks786
Forum Newbie
Posts: 7
Joined: Fri Jul 17, 2009 1:23 pm

Re: PHP Form Help Please

Post by shaks786 »

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

Re: PHP Form Help Please

Post by shaks786 »

ok,
it does not matteer,
i've solved the problem now
Thanks for the help!
Post Reply