Reputation: 57
So I want to write a link in id="id_input" and when I press the button name="b" I want that link to go to page2.php in the row $html->load_file(); and then the variable $slbl from page2.php to pass to page1.php in textarea name="desc_name".
I'm new at web programming and I'm learning so please explain to me if you want. And I tried everything I could found but without success. And because that I need explanation for this example.
page1.php
<html>
<body>
<?php
include ("page2.php");
?>
<form action="page1.php" method="post" enctype="multipart/form-data">
<div>
<div><textarea name="desc_name" rows="7" cols="50" id="id_desc" value="<?php echo (isset($slbl))?$slbl:'';?>"></textarea></div>
<div><input id="id_input" type="text" name="name_input" size="50">
<button name="b" type="button">Button</button></div>
<div>
<div><input type="submit" name="submit" value="Publish"></div>
</div>
</form>
</body>
</html>
<?php
...code for saving in mysql...
?>
page2.php
<?php
include ("simple_html_dom.php");
// Create DOM from URL or file
$html = new simple_html_dom();
$html->load_file(<!--i need here url from id="id_input"--!>);
$html = $html->find('.summary_text', 0);
$html2 = strip_tags($html);
$html2 = trim($html2);
$slbl = $html2;
?>
Upvotes: 0
Views: 54
Reputation: 3515
Why dont you use jquery for this purpose?
Try this :
<html>
<body>
<form action="page1.php" method="post" enctype="multipart/form-data">
<div>
<div><textarea name="desc_name" rows="7" cols="50" id="id_desc"></textarea></div>
<div><input id="id_input" type="text" name="name_input" size="50">
<button name="b" class="b" type="button">Button</button></div>
<div>
<div><input type="submit" name="submit" value="Publish"></div>
</div>
</form>
</body>
</html>
<script>
$(".b").click(function () {
var val = $("#id_input").val();
$.post("page2.php",{a:val},function (data){
$("#id_desc").val(data);
});
});
</script>
<?php
...code for saving in mysql...
?>
page2.php :
<?php
if(isset($_POST["a"])) {
$a = $_POST["a"];
include ("simple_html_dom.php");
// Create DOM from URL or file
$html = new simple_html_dom();
$html->load_file(); //you can use $a here as per your need.
$html = $html->find('.summary_text', 0);
$html2 = strip_tags($html);
$html2 = trim($html2);
echo $slbl = $html2;
exit;
}
?>
Upvotes: 1