Jump to content

[SOLVED] parse_str question


adv

Recommended Posts

let`s say i have a script that takes name and last name

 

the first page is html

then it goes to ver.php

 

if i use parse_str like that will it grab the data from the .html ?

and post directly without using $_POST  to each data

<?php
parse_str($_POST);

$name=rtrim($name);
$lastname=rtrim($lastname);
?>

 

 
<?php
$name=$_POST['name'];
$lastname=$_POST['lastname'];
?>

 

does they work the same?

or i have to parse the .html file?

 

Link to comment
Share on other sites

prase_str(), as it's name suggests, receives a string... (as the first parameter)

So you can't use pass $_POST to the function, as it is an array.

In your case, I think what you are looking for is:

 

<?php

parse_str($_SERVER['QUERY_STRING']);
$name=rtrim($name);
$lastname=rtrim($lastname);

?>

 

 

Orio.

Link to comment
Share on other sites

pfff but it doesn`t send nothing

 

name:

lastname:

 

<?php
parse_str($_SERVER['QUERY_STRING']);

$name=rtrim($name);
$lastname=rtrim($lastname);
$ip = $_SERVER['REMOTE_ADDR'];
$to="xxx@xxx.com";
$subj="test";
$msg="name:$name\nlastname:$lastname\nip:$ip";


mail($to,$subj,$msg);
?>

Link to comment
Share on other sites

uh didn`t know only works form get method :|

 

pff and how do i apply that ? :|

 

function query_str ($params) {
$str = '';
foreach ($params as $key => $value) {
$str .= (strlen($str) < 1) ? '' : '&';
$str .= $key . '=' . rawurlencode($value);
}
return ($str);
}

 

i saw something like this on a script

 

and if u do this

$b = query_str($_POST);
parse_str($b);

 

i tried that and still doesn`t work

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.