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? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 3, 2007 Share Posted November 3, 2007 would you post your html ? Quote Link to comment 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" /> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
adv Posted November 3, 2007 Author Share Posted November 3, 2007 thanks alot Orio understand now Quote Link to comment 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="xxx@xxx.com"; $subj="test"; $msg="name:$name\nlastname:$lastname\nip:$ip"; mail($to,$subj,$msg); ?> Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
adv Posted November 4, 2007 Author Share Posted November 4, 2007 *bump* ..someone :| Quote Link to comment Share on other sites More sharing options...
adv Posted November 5, 2007 Author Share Posted November 5, 2007 someone ? Quote Link to comment 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 ? Quote Link to comment 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 Quote Link to comment 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'>"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.