Domanda

Specifications:

  • I have a web-form that outputs the results as PHP variables.

  • Using RSForm Pro

  • Joomla! 2.5.14

  • Admin Email Output

Examples:

The 'modify the output layout':

To Approve this request, Please Add it to the Calendar:

http:///phpt/getform.php?name={Name:value}&dateFrom={from:value}&dateTo={until:value}

Output:

To Approve this request, Please Add it to the Calendar:

http:///phpt/getform.php?name=Josh Thomson&dateFrom=...etc

Problem:

The variables are output with spaces. As the variables are being attached to a URL, I was hoping to encode the variables with the correct encoding. e.g. %20 for 'spaces', so that eventually the output will look like so:

To Approve this request, Please Add it to the Calendar:

http:///phpt/getform.php?name=Josh%20Thomson&dateFrom=...etc

I am working with PHP ONLY, so please can you specify a solution that will take a variable and return an encoded variable... I assume it will look something similar like this:

$encodnameval = encodeurl($_POST['form']['name']);

Any help is greatly appreciated, Merci! Josh.

Edit: Code above changed, but still not working.

outputs to URL:

http:///phpt/getform.php?name=$encodnameval&dateFrom=...etc

Needs to work with RSForms.

È stato utile?

Soluzione 3

I found out that automatic encoding is done within the browser, so a static hyperlink of:

http://mywebsite.org/phpt/myscript.php?name={Name:value}&dateFrom={from:value}&dateTo={until:value}

is all was required for the link to produce a valid URL.

In rsforms this meant writing the HTML parts of the URL within the 'Source Editor' and the string elements within the Text Editor, and Whoila! it works!

http://amazewebs.com/demo = shows my script working with the POST method instead.

Altri suggerimenti

urlencode($string)

is exactly what youre looking for. http://de2.php.net/manual/en/function.urlencode.php

or just replace all spaces with %20 if thats the only char you need to replace

As Marlin said urlencode() will work for you..

use it as below..

let say you want to send this

 $name = 'Josh Thomson';  // $name = $_POST['form']['Name'];
 $url = 'http://phpt/getform.php?name='.$name;

what you need to do is..

$name = urlencode('Josh Thomson'); // $name = urlencode($_POST['form']['Name']);
$url = 'http://phpt/getform.php?name='.$name;

then the it will automatically become safe.. Like

http://phpt/getform.php?name=Josh%20Thomson

Feel free to ask any questions..

So this will work for you: $name = urlencode($_POST['name']); $encodnameval = 'Name: '.$name;

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top