Php post to iframe

Post Data to an Iframe

Doesn’t take any JavaScript or anything. You just have the form’s target attribute match the iframe’s name attribute.

The outer page doesn’t even reload. But it might appear to at first glance since many browsers run the page-loading spinner in the tab when an iframe reloads.

Psst! Create a DigitalOcean account and get $200 in free credit for cloud-based hosting and services.

Comments

Another great little snippet, as much as i do hate iframes because of there restrictions i do like the ability to manipulate them for file uploads.

Strange, just can’t get this to work. Uploaded a really basic page with just the form and the iframe page and it will not work. http://www.mercury14.co.uk/asdfgh/form.php Am I missing something obvious?

I have the same problem. I created the iframe.php file, but nothing appears, whilst it does in the demo. Help please.

If anyone else is having problems making this work try this for the iframe.php page: &ltp>I’m probably being loaded inside an iframe.&lt/p> &ltp>Text value: &lt?php echo $_POST[“text”]; ?>&lt/p>

I’m probably being loaded inside an iframe.</p> <p>Text value: <?php echo $_POST["text"]; ?></p> 

That’s because to render < you use a semi-colon to delimit the code, not just & lt. Right : & l t ; (remove spaces) Wrong : & l t

Читайте также:  Php http header class

Found this page while trying to solve this exact problem. I ended up using jQuery to build a GET query string and PHP to process it. I wanted to send data from a form on a page to a form in a fancybox iframe which is then submitted by AJAX – seems to work quite nicely.

Can you share how you did that? I’m trying to do the exact same thing. I have a form and when the user presses enter I want the php file to search for the data, and post to a fancybox iframe…

I recently used the same trick for an image uploader. I styled the file input by opacity:0 and its wrapper div with some nice looking image for the uploader button and its hover too. once the image is browsed or dragged, it is posted to the iframe and uploaded to the server and displays it in the seamless iframe just above it to show the resized and cropped image.
I’d love to write an article about it with all the code. All by HTML5, CSS3. I used js just to trigger form submit on change of file input.

I’m new to this and I’m having trouble.
I have a site with a css drop down menu that is 40px high, the menu content changes a lot so having the menu on each page would be a large hassle.
I’ve tried a iFrame for the menu, but the drop down parts of the menu are cut off by the iFrame. Is there a better way to do this or a trick to make the iFrame hover over the page content so the drop downs are viable?

Look up how to use PHP modularly; you use separate PHP files and load them together into one page that works like one file.
Once you edit the navigation, for example, it will be edited on all the pages.

This totally rocks! Takes my php file and loads into an iframe without refreshing the page! EXACTLY WHAT I WAS HOPING FOR! Thank you for posting this. You’ve just made one persons life much easier!

Источник

Iframe как альтернатива ajax и отправка POST запросов?

Lynn

Сначала надо рассказать про «вопрос безопасности» отправки запросов через ajax.
А то никто про него ничего не знает.

FanatPHP, я новичок, поэтому меня смущает отправка данных на сервер через ajax, например, когда я хочу сделать какие-то изменения в БД:

// Change email $('#changeEmailSave').click(function () < var email = $('#changeEmailValue'); $.ajax(< type: "POST", url: '/entry/?v=2', data: < 'email': email.val() >, success: function (data) < validResult(data); >>) >);

FanatPHP

Вы единственный, кого это смущает. Причем вы даже со второго раза не смогли написать внятным русским языком, что именно вас «смущает».

Не говоря уже о том, что если вас что-то смущает, то именно про это и надо задавать вопрос.

ThunderCat

FanatPHP, или, например, когда нужно изменить пароль в ЛК и для этого, вместо значения почты — как в примере выше — передается пароль. Смущает передача данных так «открыто»

FanatPHP

ThunderCat

С точки зрения практичности — нет, так как это полная шляпа, мы такое писали в 2005, когда аякс как явление еще не существовал, а уже в 2012 появился нормальный XMLHttpRequest здорового человека, на который все быстренько переползли.

С точки зрения безопасности вообще абсолютно монопенисуально каким способом вы отправляете пост запрос, внутренний механизм будет абсолютно одинаков.

Если возникают вопросы безопасности при отправке данных через пост — значит вы что-то не то передаете.

Отправка данных через фрейм используется редко, в основном для обхода CORS, когда надо отправить запрос на чужой сайт с показом результата запроса во фрейме и при этом удержать посетителя на своем сайте. Еще иногда этот способ используют для переадресации на какой-то сайт со скрытием Referer, правда не знаю работает ли сейчас это способ, но раньше точно использовали.

Войдите, чтобы написать ответ

Изменение CSS стилей элемента в JS?

Как добавить исключение?

Как на лету конвертировать единицы измерений?

Как получить данные из вебхука?

Как реализовать переключение тем на сайте, созданном на WordPress с конструктором Elementor?

Источник

Оцените статью