0

i have form with post method...

Input values is only links, like -http://site/see?v=ID How to get only ID and add it to $var-id="";?

2
  • 1
    If the form values are appearing in the URL then you're using GET, not POST... Commented Oct 31, 2011 at 4:33
  • http://site/see?v=ID its sample of input value @animuson Commented Oct 31, 2011 at 4:34

4 Answers 4

1

HTML:

<input type="hidden" name="link" value="http://site/see?v=12345" />

PHP:

$link = explode('=',$_POST['link']);
$link = $link[1]; // 12345
Sign up to request clarification or add additional context in comments.

Comments

0

Try to use php functions strpos & substr

Comments

0

It will depend on how much your data varies, but here's a technique that will work with more complex urls:

// assuming $url = 'http://site/see?something=blah&v=ID&foo=bar'
$qs = parse_str(substr($url, strpos($url, '?')+1));
$varId = $qs['v'];

Comments

0
<?php
$html = 'http://site/see?v=ID';
$var-id = explode('=',$html);
$var-id = $var-id[1];
?>

2 Comments

You should really look at the existing answers before posting one that was already provided ;)
lol. I sometimes have my window open too long (multitasking). Don't want to steal your thunder. +1 to you. I always prefer exploding to using regex.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.