I tried to play the songs and pass the dynamic id to the controller.But I tried this code.
<?php
$i = 1;
foreach ($view as $row)
{
echo "<tr>";
echo "<td>".$i."</td>";
echo "<td>"."<a href='<?php echo base_url();?>admin/play/$row->audio'".$row->audio."</a></td>";
$i++;
echo "</tr>";
}
?>
In inspecting the element anchor shows the direct php code instead of localhost/bla/bla/ how can i fix this? my controller name is play and i want to pass the value of its the particular name.Is my concatenation is correct?
You are opening php tags twice. make it like this:
<?php
$i = 1;
foreach ($view as $row)
{
echo "<tr>";
echo "<td>".$i."</td>";
echo "<td><a href='" . base_url('admin/play' . $row->audio) . "'>" . $row=>audio . "</a><td>";
$i++;
echo "</tr>";
}
Related
I want to put action button in this mail format Using Yii2 ..
So that releveant person can take a certain actions (Accept or Reject) through mail itself.
Is there any way to send encrypted key or anything else so that particular usr can perform their operation using mail it self.?
As of now i am able to send only mail with normal text body , i want to send particular action link with button along with this mail.
How can i achieve this ?
Any help will be highly appriciated.
Thanks in Advance.
My Controller Code.
/* Sending Mail Function */
public function Sendemail($request, $receiver, $subject, $email_body) {
$empmodel = Employee::find()->where('EmployeeNo = "' . $request->createdby . '" ')->all();
$data = ServreqItems::find()->where('srno=' . $request->srno)->all();
$content = "<html><body>";
$content .= "<table align='center' width='70%' bgcolor='#e0e0e0' cellpadding='0' cellspacing='0' border='0'>";
$content .= "<tr><td>";
$content .= "<table align='center' width='100%' cellpadding='0' cellspacing='0' style='border:dashed #FFA500 2px; max-width:650px; background-color:#fff; font-family:Verdana, Geneva, sans-serif;'>";
$content .= "<thead>
<tr height='80'>
<th colspan='4' style='background-color:#f5f5f5; border-bottom:solid 1px #bdbdbd; font-family:Verdana, Geneva, sans-serif; color:#333; font-size:24px;' >" . $request->FormsName . " Details</th>
</tr>
</thead>";
$content .= "<tbody>
<tr align='center' height='10' style='background-color:#FFA500; font-family:Verdana, Geneva, sans-serif;'></tr>";
$empmdl = Employee::find()->where('EmployeeNo = "' . Yii::$app->session['username'] . '" ')->all();
for ($e = 0; $e < count($empmdl); $e++) {
$content.= "<tr>
<td colspan='4' style='padding:15px;'>
<p style='font-size:20px;'>Hi' " . $empmdl[$e]->EmployeeName . " !!! " . $email_body . "</p>
<hr />";
}
for ($i = 0; $i < count($data); $i++) {
$content.= '<tr><td style="padding-left:15px;padding-bottom:15px;">' . $data[$i]->fid->filable . '</td> <td style="padding-right:255px;"> : ' . $data[$i]->fivalue . '</td></tr>';
}
$content .= "<tr height='25'>
<td colspan='4' align='center' style='background-color:#f5f5f5; border-top:dashed #FFA500 2px; font-size:12px; '>
</td>
</tr>
</tbody>";
$content .= "</table>";
$content .= "</td></tr>";
$content .= "</table>";
$content .= "</body></html>";
$sender = 'test#abc.in';
$message = Yii::$app
->mail
->compose()
->setFrom($sender)
->setTo($receiver)
->setSubject($subject)
->setHtmlBody($content, ' text/html')
;
Yii::$app->mail->getTransport()->start();
Yii::$app->mail->send($message);
Yii::$app->mail->getTransport()->stop();
echo '<script>alert("Email Sent Successfuly")</script>';
}
encrypt url like as #kumar Rakesh explained
$id = $emp_id;
$static_key = "afvsdsdjkldfoiuy4uiskahkhsajbjksasdasdgf43gdsddsf";
$ids = $id . "_" . $static_key;
$b_id = base64_encode($ids);
Then you can make two links for Accept and Decline.
$url1 = base_url('Class_name/action_name/') . "/?id=" . $b_id."&action=accept";
$url2 = base_url('Class_name/action_name/') . "/?id=" . $b_id."&action=reject";
And in your Sendemail function do this:
$content .= "<p><a target='_blank' href='" . $url1 . "'>Accept</a></p>";
$content .= "<p><a target='_blank' href='" . $url2 . "'>Reject</a></p>";
As like your question , I have sent a link in my email for forget password.. This link Work for different functionality for different users. I am working it with codeigniter but it also work fine for all php frameworks.
e.g.
$id = $emp_id;
$static_key = "afvsdsdjkldfoiuy4uiskahkhsajbjksasdasdgf43gdsddsf";
$ids = $id . "_" . $static_key;
$b_id = base64_encode($ids);
$url = base_url('Access/newpassword/') . "/?id=" . $b_id;
Now $url is secure encrypted link. And this url send in body part of message e.g.
echo "<p><a target='_blank' href='" . $url . "'>Change Password</a></p>";
Send it in email . After click of user at this link in his/her email.. you can achive this reverse process of all thing eg..
$ids = $this->input->get('id');
$urlData = array('ids'=>$ids);
$iddecoded = base64_decode($ids);
$idsalt = explode('_', $iddecoded);
$id = $idsalt[0];
$salt = $idsalt[1];
Now $id is employe Id.. Try this php code. It will be working Fine for everyone.
I am using ajax to call a method from the server that returns a string data. However I get the following error.
PHP Notice 'yii\base\ErrorException' with message 'Trying to get
property of non-object'
probably this line $first_day=$row->tblStaff2->first_day_service; gives the error.
public function actionGet_loyalty() {
$model = \common\models\staffs\TblStaff::find()->joinWith('tblStaff2')->all();
$string = "<table class='table table-striped'><tr><th>Name</th><th>Number of Years</th></tr>";
foreach ($model as $row) {
$first_day=$row->tblStaff2->first_day_service;
$midname = ucwords($row->midname);
$name = ucwords($row->firstname) . " " . $midname[0] . ". " . ucwords($row->lastname);
$string.="<tr>"
. "<td>" . $name . "</td>"
. "<td>" . $first_day . "</td>"
. "</tr>";
}
$string.="</table>";
return $string;
}
TblStaff relation
public function getTblStaff2() {
return $this->hasOne(TblStaff2::className(), ['staff_id' => 'id']);
}
I have modified your code. Find it below
public function actionGet_loyalty() {
$model = \common\models\staffs\TblStaff::find()->all();
$string = "<table class='table table-striped'><tr><th>Name</th><th>Number of Years</th></tr>";
foreach ($model as $row) {
//What I added
foreach($row->tblStaff2 as $value){
$first_day = $value->first_day_service;
//Here is where it stopped
$midname = ucwords($row->midname);
$name = ucwords($row->firstname) . " " . $midname[0] . ". " . ucwords($row->lastname);
$string.="<tr>"
. "<td>" . $name . "</td>"
. "<td>" . $first_day . "</td>"
. "</tr>";
}
}
$string.="</table>";
return $string;
}
You can remove the comments i added to it when you get it working.
I am trying to finish my school project.
This is what my site looks like:
I am fetching daha via the "Getir" button using AJAX. This is working very well but I want to make the second row editable.
foreach ($rows as $row) {
echo "<tr>";
echo "<td>".$row['uyeid']."</td>";
echo "<td>".$row['ad']."</td>";
echo "<td>".$row['soyad']."</td>";
echo "<td>".$row['eposta']."</td>";
echo "<td>".$row['uyestatusu']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$duzenlenemez</td>";
echo "<td>".$row['ad']."</td>";
echo "<td>".$row['soyad']."</td>";
echo "<td>".$row['eposta']."</td>";
echo "<td>".$row['uyestatusu']."</td>";
echo "</tr>";
}
}
I am ready to supply extra code if anyone needs it to figure out more.
For anyone interested and found this subject one google I am writing this:
As I said I wanted to make second row editable so I needed to wrote data to inputs. Like this:
foreach ($rows as $row) {
echo "<tr>";
echo "<td>".$row['uyeid']."</td>";
echo "<td>".$row['ad']."</td>";
echo "<td>".$row['soyad']."</td>";
echo "<td>".$row['eposta']."</td>";
echo "<td>".$row['uyestatusu']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$duzenlenemez</td>";
echo "<td><input type='text' value='".$row['ad']."'/></td>";
echo "<td><input type='text' value='".$row['soyad']."'/></td>";
echo "<td><input type='text' value='".$row['eposta']."'/></td>";
echo "<td><input type='text' value='".$row['uyestatusu']."'/></td>";
echo "</tr>";
}
}
Output picture: http://puu.sh/8uSDl.png
I am attempting to display some info from an infoblox device. When I run this code in a browser using an html post, the table that displays MAC address entries does not display the values from the api. When I run this code in the unix command-line, the variables show up appropriately. Any Advice?
#!/usr/bin/perl
use strict;
use Infoblox;
use CGI;
my $cgi = new CGI;
print
$cgi->header() .
$cgi->start_html( -title => 'Form Results') .
$cgi->h1('Form Results') . "\n";
my #params = $cgi->param();
my $username = $cgi->param('username');
print '<table border="1" cellspacing="0" cellpadding="0">' . "\n";
foreach my $parameter (sort #params) {
print "<tr><th>$parameter</th><td>" . $cgi->param($parameter) . "</td></tr>\n";
}
print "</table>\n";
print "<p>$username</p>";
print $cgi->end_html . "\n";
#Create a session to the Infoblox appliance
my $session = Infoblox::Session->new(
master => "server", #appliance host ip
username => "username", #appliance user login
password => "password" #appliance password
);
unless ($session) {
die("Construct session failed: ",
Infoblox::status_code() . ":" . Infoblox::status_detail());
}
print "Session created successfully\n<br>";
my #list = $session->get(
object => "Infoblox::DHCP::MAC",
filter => "macfilter",
);
my $nextobject = $list[0];
print <<EOF;
<br>
<table>
<tr>
<th>MAC</th>
<th>Description</th>
<th>UserID</th>
<th>Expiration</th>
</tr>
EOF
foreach my $test ( #list ) {
print "<tr>";
print "<td> $test->mac()</td>";
print "<td>" . scalar($test->comment()) . "</td>\n";
print "<td>" . scalar($test->username()) . "</td>\n";
print "<td>" . scalar(localtime(scalar($test->expiration_time()))) . "</td>\n";
print "</tr>";
}
exit (0);
I had incorrect permissions. The script was running as user nobody and would not display the items correctly on the web page.
i have the following code in my zf project :
$index = Zend_Search_Lucene::open(APPLICATION_PATH . '/cache/search_index');
$doc = new Zend_Search_Lucene_Document();
$title = "سلام سینا xxx sad";
$doc->addField(Zend_Search_Lucene_Field::Text('title', $title));
$index->addDocument($doc);
$index->commit();
$index->optimize();
echo "Index contains " . $index->count() . " documents.\n\n";
$results = $index->find('xxx');
foreach ($results as $res) {
var_dump($res->title);
}
when var_dump performs output ->
string(39) "سینا جان xxx sad"
when i user utf_decode
string(25) "س�?ا�? س�?�?ا xxx sad"
how can i decode that correctly ! :(?
i already used the solution in this SOF quesion -> lucene encoding problem in zend framework
but not works and a notice error added about iconv !
plz help :)
Fixed by this code:
$index = Zend_Search_Lucene::open(APPLICATION_PATH . '/cache/search_index');
$doc = new Zend_Search_Lucene_Document();
$title = "سلام سینا xxx sad";
$doc->addField(Zend_Search_Lucene_Field::Text('title', $title,"UTF8"));
$index->addDocument($doc);
$index->commit();
$index->optimize();
echo "Index contains " . $index->count() . " documents.\n\n";
var_dump($index->getDocument(9));
echo "Search";
$results = $index->find('سینا');
foreach ($results as $res) {
var_dump($res->title);
}
die(1);