Jump to content

how to send a smarty variable from tpl to php using href ?


Recommended Posts

<a href="checksamdel.php?tex={$myArray1[$foo]}" title="Delete" class="delete"><i class="icon-trash"></i> Delete	</a>

The above code is found in sample.tpl

 

here the smarty variable is {$myArray1[$foo]}

 

how can i send this value to checksamdel.php

 

my checksamdel.php is here

<?php

if( $_GET["tex"] )
{
   $name = $_GET["tex"];
}
echo"<script>alert(".$name.");</script>";
$id_product =$name;
mysql_connect("localhost","root","");
mysql_select_db("prestashop");

$result=mysql_query('DELETE FROM ps_check_module WHERE textname = '.$id_product);

return;

i am not getting this value in checksamdel.php

 

kindly help me thanks in advance.

Link to comment
Share on other sites

OK i solved it we can use 2 methods

1.<a href

2.<a onclick="fun({$myArray1[$foo]})"

 

Thanks for your reply

 

But i have one more doubt 

in sample.tpl i have done this

<a onclick="editfun({$idArray[$foo]})" title="Edit" class="edit btn btn-default"><i class="icon-pencil"></i> Edit</a>



<script language="javascript" type="text/javascript">
function editfun(id_combination)
	{
	            alert("We are going to update it");
			    
			    $.post( "checksamup.php",{ name:id_combination},function(data) 
				                                    { alert("Updation On Process");
                                                    }).done(function() { alert( "Updation successfull" );})
                                                      .fail(function() { alert( "error" );}); 
		
	alert(id_combination); location.reload();		
			  
    }
 </script>

and in checksamup.php

<?php

if( $_POST["name"] )
{
   $name = $_POST["name"];
}
$_SESSION['nam']=$name;
<form method="post" action="checksamedit.php">
NAME: <input type="text" name="text1">
PRICE:<input type="number" name="price1">
<input type="submit">
</form>
$id_product =$name;
echo"<script>alert('".$name."');</script>";
?>

and in checksamedit.php

<?php
$id=$_SESSION['nam'];
$name_update=$_POST['text1'];
$price_update=$_POST['price1'];
echo"<script>alert('".$id."');</script>";
mysql_connect("localhost","root","");
mysql_select_db("prestashop");
$result=mysql_query('UPDATE `ps_check_module` SET textname='.$name_update.', price='.$price_update.' WHERE `id_check_module` = '.(int)$id.'');
return;

iam not able to display the form

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...