Jump to content

[SOLVED] Collect form data, use variables, concatenate into string and fopen string?


mosey

Recommended Posts

This is a continuation (sort of) from my previous post, but I would really appreciate some help with this!:D

 

I currently have a PHP file that already includes variables such as 'username' and 'password' (for authentication), but I would like to collect the form data submitted,  concatenate everything into one string, and then open up this string (which is essentially a url)

 

I undrstand (with thanks to schme16) that I have to use

$_POST['name_of_form input']

 

to retrieve the data, but after that I would like to put all of these into one string that looks like

 

http://www.wbsite.com/something.php?username=$username&password=$password&msg=$message

 

and then use fopen to load this url.

 

Thanks in advance for any help! :D

<?php

$username = $_POST['username'];
$password = $_POST['password'];
$message = $_POST['message'];

$url = "http://www.wbsite.com/something.php?username=$username&password=$password&msg=$message";

$file = fopen($url);

?>

 

Give that a shot =]

 

ReDucTor: Thanks for the suggestion :)

 

I've just tried to read up abit on get_file_contents and have understood it is for PHP5 (which isn't a problem)

 

But I was wondering how I would apply it here (as a PHP newbie)?

 

Would it literally be replacing the $file part ith

get_file_contents($url)

 

And for the encode part, is it something like

 

$username = urlencode($_POST['username'])'

 

or can I use this function later? I guess it would be easiest if I could encode all the parameters in one go or something.

 

Thanks! :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.