adv Posted November 3, 2007 Share Posted November 3, 2007 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 https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/ Share on other sites More sharing options...
rajivgonsalves Posted November 3, 2007 Share Posted November 3, 2007 would you post your html ? Link to comment https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384285 Share on other sites More sharing options...
adv Posted November 3, 2007 Author Share Posted November 3, 2007 <input type="text" name="name" size="20" maxlength="20" /> <input type="text" name="lastname" size="20" maxlength="20" /> Link to comment https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384291 Share on other sites More sharing options...
Orio Posted November 3, 2007 Share Posted November 3, 2007 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 https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384294 Share on other sites More sharing options...
adv Posted November 3, 2007 Author Share Posted November 3, 2007 thanks alot Orio understand now Link to comment https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384357 Share on other sites More sharing options...
adv Posted November 3, 2007 Author Share Posted November 3, 2007 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="[email protected]"; $subj="test"; $msg="name:$name\nlastname:$lastname\nip:$ip"; mail($to,$subj,$msg); ?> Link to comment https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384378 Share on other sites More sharing options...
Orio Posted November 3, 2007 Share Posted November 3, 2007 This works if your form is in the method GET. For POST you could do something like this: <?php foreach($_POST as $key=>$val) $$key = $val; ?> Orio. Link to comment https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384390 Share on other sites More sharing options...
adv Posted November 3, 2007 Author Share Posted November 3, 2007 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 https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384396 Share on other sites More sharing options...
adv Posted November 4, 2007 Author Share Posted November 4, 2007 *bump* ..someone :| Link to comment https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384522 Share on other sites More sharing options...
adv Posted November 5, 2007 Author Share Posted November 5, 2007 someone ? Link to comment https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384915 Share on other sites More sharing options...
rajivgonsalves Posted November 5, 2007 Share Posted November 5, 2007 well exactly what do you want to do put all your $_POST varaibles in the query string ? Link to comment https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384924 Share on other sites More sharing options...
adv Posted November 5, 2007 Author Share Posted November 5, 2007 yes that and with form method POST Link to comment https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384974 Share on other sites More sharing options...
rajivgonsalves Posted November 5, 2007 Share Posted November 5, 2007 well I think this is the screnario first you get them from GET and then you wanna put them in a post the best way to do this is use hidden input types in your form tag foreach ($_GET as $strKey => $strValue) { echo "<input type='hidden' name='$strKey' value='$strValue'>"; } Link to comment https://forums.phpfreaks.com/topic/75922-solved-parse_str-question/#findComment-384976 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.