Facebook iframe - how to send form (POST method)? - php

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.

Related

HTML/PHP : how can I have multiple form that send informations to the same page?

My problem is this :
I got 2 forms that are supposed to send different informations to the same page (via POST method). Each form has a submit button. However when I press any of the button, information from both forms are sent to the page.
Is it normal or is there something that I do wrong ?
I can already tell you without looking at your HTML.
You have to properly close the first form before opening the second. Easy mistake to make.
<form method="post" action="page.php">
<input type="text" name="something" />
<input type="submit" value="Submit" />
</form>
<form method="post" action="page.php">
<input type="text" name="somethingelse" />
<input type="submit" value="Submit" />
</form>

User input not showing in search form

I have a free form search that I moved from my main content to my header. Once I moved the form into the header the text inside of it stopped showing. The placeholder works but when you begin typing it is completely blank. The search and the functionality work perfectly, I just cannot see what I am typing. Any ideas?
<form class="search" action="/all-results/" method="get">
<fieldset>
<span class="text"><input name="searchProducts" value="All" type="hidden">
<input type="hidden" name="search_selection" value="all">
<input name="byString" id="s" type="text" value="" placeholder="<?php echo __('Search','Avada'); ?>" /></span>
</fieldset>
<form name="input" action="/all-results/" method="get">
<input type="submit" id="search_button" value="Search">
</form>
</form>
Your HTML is invalid. You can not nest a <form> element inside another <form>. Messing up forms and tables are two of the best ways to produces peculiar browser behaviour, so my guess is that this is your problem.
If you correct your HTML (validate it!) and the problem persists, then post a minimal HTML page with CSS so that there is something for us to debug.

Sending Form variables to a external page and get the html from server

I don't know if this is possible, what I want is just to get the html or the plain-text from the result of a form sent to a external page.
In this case, I have a form that send the variables to a external server and the result goes to the iframe, how I retrieve the html or text from the iframe? This is the correct way?
I'm trying to do this just to simplify a repetitive process here on my agency...
<form name="form" method="post" action="https://www.externalpage.com" target="iframe">
<input type="hidden" name="a" value="0000"/>
<input type="hidden" name="b" value="0001" />
<input type="hidden" name="c" value="0002" />
<p>
<input type="submit" id="button" value="Submit" />
</p>
</form>
<iframe name="iframe" scrollbars="no"></iframe>
Assuming from the tags you are using jquery
var myresult = $('iframe[name="iframe"]').html();
Should do the work.
//edit: just noticed the iframe is from an external domain, it might be subject to the same origin policy, in this case the above code might not work

add query on href using input

I have an
<input type=text name=search />
and I wanted to add the value of input to my href
<a href='index.php?search=$search>submit</a>
But I think that won't work on php alone right?
How can I add the value of my input to my href as it clicks?
NOTE: need to appear in the browser url menu this way
index.php?search=anyvalue
as soon as they click it. because I'm using pagination
Straight HTML - no PHP or JavaScript Needed
<form action="index.php" method="get">
<input type="text" name="search" />
<button type="submit">Submit</button>
</form>
Once clicked it will take the user to: index.php?search={value of input}
For pagination to work it would be:
Page 2
Page 3
try this:
<form method="get" action="index.php">
<input name="search" type="text" />
<input type="submit" />
</form>
If that's not what your looking for just elaborate a bit on what you are trying to achieve.
you must open a php tag like this:
<a href='index.php?search=<?php echo $search;?>' >submit</a>
but it work after submitting the form.
use javascript

Youtube API upload from website WITH diff. TITLES

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>

Categories