I am using this code to make a upload-form for my website.
Youtubeuploader
It works perfect, but I got ONE problem.
I want a form to define the title.
Right now, all the videos are given the title "Example"
I want the user to write their own title for their video.
I've tried making a input with id and name "title", and tried to use $_POST['title'], but it didn't work. The video didn't even upload.
Anyone knows how to do this?
I've looked at all the YouTube Data API code and tried everything.
Thanks.
Given the link you posted, you have to give $youtube_video_title the value from your form.
I mean like this (not secure, always sanitize and filter):
$youtube_video_title = $_POST['title'];
UPDATE :
try to replace the form code with this one
<form action="<?php echo($response->url); ?>?nexturl=<?php echo(urlencode($nexturl)); ?>" method="post" enctype="multipart/form-data" onsubmit="return checkForFile();">
Title : <input id="title" type="text" name="title"/>
<input id="file" type="file" name="file"/>
<div id="errMsg" style="display:none;color:red">
You need to specify a file.
</div>
<input type="hidden" name="token" value="<?php echo($response->token); ?>"/>
<input type="submit" value="go" />
</form>
Related
I am trying to create a form in HTMl. However, I don't know how to make the action attribute work. Below I have attached my code. The form appears, but when I enter the information, it isn't added to the PHP file.
<form action="info.php">
<p>Username:
<input type="text" name="username" size="15" maxlegnth="30" />
</p>
</form>
Another question. When I'm linking things (images, videos, etc.) to my website, do I need to attach the whole link (file:///C:/Users/Name/Desktop/Web%20Developement%20Code/notes.php) or is notes.php enough?
Thank you!
You need to set method="post" to form, and add submit button, then you will be able to get your information.
<form method="post" action="info.php">
<p>Username:
<input type="text" name="username" size="15" maxlegnth="30" />
</p>
<p><input type="submit"></p>
</form>
Then in info.php:
<?php
$username = $_POST['username'];
echo($username) //or any other actions with this variable
In response to your second question, you don't need to provide the full path. It is enough to specify the path from the root folder of your project.
Another question. When I'm linking things (images, videos, etc.) to my website, do I need to attach the whole link (file:///C:/Users/Name/Desktop/Web%20Developement%20Code/notes.php) or is notes.php enough?
This is simplified code of index.php :
<form action="index.php" method="get">
<input type="text" name="course">
<button>Find</button>
</form>
Suppose, in the text field "ADAM" is put and after pressing Find button url becomes
myweburl/index.php?course=ADAM
But I want to make it
myweburl/index.php?course=ADAM#courseid
NB: Here courseid is a div id name inside index.php. By this way, I will be able to scroll down the result area.
Do you know how to do this?
Why not do it in a more legitimate way
<form action="index.php" method="get">
<input type="text" name="course">
<input type="hidden" name="courseid" value="<?php echo $courseId;?>">
<button>Find</button>
</form>
Then you get a url like this
myweburl/index.php?course=ADAM&courseid=1234
Now you dont have to do any text manipulation in the script that processes the data you just use
$_GET['course']
$_GET['courseid']
Simply add the hashtag to the action attribute.
The browser would know to move it to the end of the url string (after the GET parameters).
<form action="index.php#courseID" method="get">
<input type="text" name="course">
<button>Find</button>
</form>
Would result:
index.php?course=xxxx#bla
Tested on Chrome, if someone find other results please update.
So I have a very simple file upload form, code below...
<form enctype="multipart/form-data" action="$theaction" method="POST">
<input name="source" type="file">
<input name="message" type="text" value="">
<input type="submit" value="Upload"/>
</form>
I was wondering if I can set with php the source of the file upload? Something like..
<?php $file = "http://mywebsite.com/path/to/img.jpg"; ?>
<input name="source" type="file" src="<?php echo $file; ?>">
I've googled it but I can't come up with anything. I feel like I'm just not using the proper vocabulary, but any help would be greatly appreciated!
I concur #IMSoP statement.
Instead of populating the input tag value, I would rather create an element (div) to display the thumbnail version of the image that was uploaded by the user that way it makes it clear to the user that a file exist and also I would give them the option to edit for uploading a new file & delete for deleting the file.
Accidentally, I discovered that whenever there is a backslash at the end of a search, the page after clicking submit will return a broken search form.
In my case, the submit button turned into a text area.
Using Google Chrome's "inspect element" I saw that my search form turned into this:
<form method="get" action="">
<input type="hidden" name="type" value="books">
<input type="text" name="search" value="\"> <input type=">
</form>
</div></div></div><div id=" sidebar"="" class="sidebar widget-area"></form>
The following code is my form. I am guessing that I need to sanitize/escape the value from the input type text? But why isn't esc_attr() working?
<form action="" method="get">
<input type="text" name="search" value="<?php echo esc_attr(stripslashes($_GET['search'])); ?>">
<input type="submit" value="Search">
<input type="checkbox" name="title">
</form>
P.S. I am using this custom search form to search custom fields and display the resulting custom post types using Pods Plugin. It doesn't appear that this is a Pods plugin issue though.
https://github.com/pods-framework/pods/issues/1620
Also, this doesn't appear to be a conflict from another theme or plugin.
I've made some test, I'm guessing that your question was missunderstood, this code should work:
<form action="" method="get">
<input type="text" name="search" value="<?php echo urldecode($_GET['search']); ?>">
<input type="submit" value="Search">
<input type="checkbox" name="title">
</form>
You can check the php urldecode function for extra info.
Decoding an url is the oposite of encoding it, when a special character is submited it needs to be encoded, when you want to display it you'll have to decode it.
EDIT:
After the form is submitted, when its values are processed, then you have to use esc_attr(stripslashes($_GET['search'])) so that the value becomes encoded and sql-injections and other format issues are avoided, again this has to happen in the php file where the form is processed, usually after an if ($_GET) statement.
I have tried dozens of sanitation and escaping. But in the end, only preg_replace worked against that annoying backslash.
I have very simple form (the file is called message.php):
<?php
print_r($_POST);
?>
<form method="post" target="_top" action="<?php echo CANVAS_URL;?>message.php">
<input type="text" name="your_name" />
<input type="hidden" name="signed_request" value="<?php echo $_REQUEST['signed_request'];?>" />
<input type="submit" name="send" />
</form>
I found one solution of this issue - put into the form hidden input with the signed_request - I did it but unfortunately I am still facing with this problem -- I cannot retrieve sent POST data.
If I change the method to method="get", everything is working well, but I would need to data from POST.
Could anyone help me, how to solve this problem? Thanks!
Try this. I don't believe you need to use target in FB canvas aps anymore. Also a form ID would be good.
<form method="POST" id="my_form" action="message.php">
<input type="text" name="your_name" />
<input type="hidden" value="<?php print $_POST["signed_request"] ?>" name="signed_request" />
<input type="submit" name="submit" />
</form>
POSTing to Canvas URLs (as in http://apps.facebook.com/namespace) is simply not supported.
But why post to the top window instead of simply staying within the iframe? It's way better as it doesn't require the entire page to be reloaded, only the iframe.