Jump to content

How to get a $_GET from a from


i73
Go to solution Solved by i73,

Recommended Posts

youtube.com/watch?v=vdasdwd

 

I just need to pass the variable 'v' over to the post form 

<form id='upload' action='video.php' method='post' accept-charset='UTF-8'">
<fieldset class='textbox'>

<input id='youtube_code' name='youtube_code' value='' type='youtube_code' placeholder='URL of youtube video'  maxlength='100' style='background-color:#555;color:#000; width:50%;'>
			
<input type="submit" name="submit" value="Submit">

</fieldset>
</form>

How could I do that on video.php

is it like? 

$youtube_code=$_POST['youtube_code'];
or
$youtube_code=$_POST['v'];

Thanks for your help! 

Link to comment
Share on other sites

Is this what you're looking for:

<input id='youtube_code' name='youtube_code' value='<?php echo $_GET['v']; ?>' type='text' placeholder='URL of youtube video'  maxlength='100' style='background-color:#555;color:#000; width:50%;'>

Note that I changed the input type to "text".

Yes! thank you, I was in a copy paste frenzy when I changed the type :/ 

 

But the code wont pass the variable "v" to the video.php script. is there a way I can do that? I understand the concept of what you are saying there, I just don't see how it can just pass that variable over the post. 

I have been trying to do this all day :,(

Edited by i73
Link to comment
Share on other sites

When the html form has been submited from the client (browser) to the application server, you should grab this value from the app server using some server side language like php for instance and which will send the value to database server. Then you should grab the value back from this database and write it down to application server which will pass the value to the client (browser). That's all you have to do :)

Edited by jazzman1
Link to comment
Share on other sites

When the html form has been submited from the client (browser) to the application server, you should grab this value from the app server using some server side language like php for instance and which will send the value to database server. Then you should grab the value back from this database and write it down to application server which will pass the value to the client (browser). That's all you have to do :)

Yeah, I have that. I have everything but this done. 

if (isset($_POST['submit'])){
    $user_ip=$_SERVER['REMOTE_ADDR'];
    $video_name=$_POST['video_name'];
   *ect
}



I just need to know how to grab that variable V on this script. :/

Link to comment
Share on other sites

Lol, 

I have the user put in the youtube URL into a text box. 

Lets say it is, http://www.youtube.com/watch?v= J4o2vOdapms

 

I need "v=#######" so the value of V . I will be dropping the www.youtube.com

Is there a way to take that from the post script on the next php file? I know I cant use a $_post Would a $_get work some way? 

 

Well this site auto loads the V=#######

Edited by i73
Link to comment
Share on other sites

  • Solution

I got it! thanks for your help!!!

$link = "http://www.youtube.com/watch?v=oHg5SJYRHA0&lololo";
$video_id = explode("?v=", $link); // For videos like http://www.youtube.com/watch?v=...
if (empty($video_id[1]))
    $video_id = explode("/v/", $link); // For videos like http://www.youtube.com/watch/v/..

$video_id = explode("&", $video_id[1]); // Deleting any other params
$video_id = $video_id[0];
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.