سؤال

im using pho forms in dreamweaver, i did a comments form, as in users will be able to comment about the items in my website, each individually. But its the same form for every page, which is why i need for the form to retreive the tittle of the page where it was lauch from... Its like a

    $_get and $post 

I need that when the user clicks on the link "Comment" the form would launch with the Item's Field auntofilled with the item's name which is located in the previous page... Is there a way i can say in php to retreive the Name and paste it in the next page? In php, or maybe in js or anyway... Help!

هل كانت مفيدة؟

المحلول 2

There are hundreds of things that may vary from what you are describing.

Are those pages static?

Is there a php that dynamically retrieves them from the database?

Assuming that you already have the PHP variable that prints the title of the "item" you have, it's quite simple. You should just add a field in the form. Something like:

<?php 
  print '<input type="hidden" name="item_title" value="'.$item_title_var.'"/>';
?>

If your question is about retrieving the item title on each page, without having access to the real page data from PHP, then maybe you can combine the following JS and PHP:

PHP Code:

<?php 
  print '<input type="hidden" name="item_title_field" id="item_title_field"/>';
?>

JS Code:

<script type="text/javascript">
  window.onload = function() {
    var el = document.getElementById("your_item_title_id");
    document.getElementById("item_title_field").value = el.innerHTML;
  }
</script>

Just make sure that there is no actual HTML in the item title, but just the text. It would simplify things for you.

نصائح أخرى

You can set a hidden field in each form putting the form's name in it.

For E.g:

<input type="hidden" name="hidden_field" value="registration form" />

In PHP:

<?php
echo $_GET['hidden_field'];
?>

In this way you can easily get the name of each form.

There are multiple ways to do this but as per your question you looks like PHP NOOB so i answered in the same way.

Well. Basically... if you communicate with your server between two pages, all you have to do is submit the information you need for your next page. I say "if" because your pages could also be simple parts showed or hidden via javascript, and I don't know that right now.

See @Moeed Farooqui for more precision.

you can add an field on each form and then, when you receive the request you can get the product id with $_POST['product'];

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top