Fetching data into textbox - forms

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

Related

How to right align several lines of text in PHP - newbie

I'm trying to right align a date and 6 lines of text on a letterhead using PHP, but either break the PHP code or it isn't right aligning all the text lines.
This is the existing PHP code I've adjusted to this point which right aligns the date and the first two lines, but the rest of the text lines are still on the left.
The end result I want to achieve is to align the date and the 6 lines of text after the date on the right side of the page.
<?php
echo "<br />";
echo "<br />";
echo "<div align='right'>";
echo date("d/m/Y") . "</div><br />";
echo "<br />";
echo "<br />";
$user_info = wp_get_current_user(1);
echo "<div align='right'>";
echo $user_info->first_name . " " . $user_info->last_name . "\n";
echo "Job Title</div>" . "\n";
echo 'Email: ' . $user_info->user_email. "\n";
echo 'Mobile: ' . $user_info->mobile_number. "\n";
echo 'Web Address: ' . $user_info->webaddress1. "\n";
echo 'Facebook Page: ' . $user_info->facebook. "\n";
echo "<br />";
echo "<br />";
echo "<hr />";
echo "Dear " . $_POST["c_name"] . "," . "\n";
I'm very new at this so thanks so much for any help and suggestions.
change your code at line 9
from echo "<div align='right'>";
to echo "<div style='text-align:right'>";

Send an HTML email with an attachment in unix either using mail,mailx or sendmail

I am trying to send an HTML email along with few attachments, but i when m not using
Content-Type: text/html
in header then i am able to send the attachment , but HTML part of the email is displayed as below :-
<html>
<body>
<p>This is the body content</p>
</body>
</html>
but when m using the
Content-Type: text/html in header am able to see the HTML part of the email as below :-
This is the body content
But in this case m not able to send the attachment.
Below is the 2 sets of code am using
For set 1 :-
FILES="$(ls /dir_with_the_list_of_files_to_be_sent | awk '{print $0}' | tr '\n' ' ')"
(
echo "To: abc#abc.com"
echo "Subject:Extract List ";
echo "Content-Type: text/html"
echo
echo "<html>"
echo "<body>"
echo "<font face='Courier New' size='1'>"
echo "<h1>Hi All,</h1>"
echo "<h1>Below are the path </h1>"
echo "<br>"
echo "<font size="4"><p>Thanks & Regards,<br />
<br />
echo "`for f in $FILES ; do uuencode "$f" "$f" ; done `"
ABC</p></font>"
echo "</font>"
echo "</body>"
echo "</html>"
) | /usr/sbin/sendmail -t
For set 2 :-
FILES="$(ls /dir_with_the_list_of_files_to_be_sent | awk '{print $0}' | tr '\n' ' ')"
(
echo "To: abc#abc.com"
echo "Subject:Extract List ";
echo
echo "<html>"
echo "<body>"
echo "<font face='Courier New' size='1'>"
echo "<h1>Hi All,</h1>"
echo "<h1>Below are the path </h1>"
echo "<br>"
echo "<font size="4"><p>Thanks & Regards,<br />
<br />
echo "`for f in $FILES ; do uuencode "$f" "$f" ; done `"
ABC</p></font>"
echo "</font>"
echo "</body>"
echo "</html>"
) | /usr/sbin/sendmail -t
Could someone please suggest how can i send both the HTML part of email and attachment from unix.
Thanks in advance.

Send action links with buttons in Mail using YII2

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 cannot pass the id to the controller?

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>";
}

PHP Form fields will not send to email

I have created a send to email PHP script.
The form seems to work correctly when sending only one field (the message field) but as soon as other fields are added, the form ceases to be emailed on to the inbox (yet the form still fires correctly and reroutes to the thankyou just fine.)
Here is the code I currently have, this does not work
<?php
$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$services = $_REQUEST['services'] ;
$message = $_REQUEST['message'] ;
if (!isset($_REQUEST['email'])) {
header( "Location: feedback.html" );
}
elseif (empty($email) || empty($message)) {
header( "Location: error.html" );
}
else {
mail( "info#website.co.uk", "Message via your website!",
$name, $services, $message, "From: $email" );
header( "Location: thankyou.html" );
}
?>
This is the previous code, this does work, but only displays the message
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
if (!isset($_REQUEST['email'])) {
header( "Location: feedback.html" );
}
elseif (empty($email) || empty($message)) {
header( "Location: error.html" );
}
else {
mail( "info#website.co.uk", "Message via your website!",
$message, "From: $email" );
header( "Location: thankyou.html" );
}
?>
This is the HTML for the form:
<form method="post" action="sendmail.php">
<label>Name:</label> <input name="name" type="text" /><br />
<label>Email:</label> <input name="email" type="text" /><br />
<label>What service do you require?:</label> <input name="services" type="text" /><br />
<label>Message:</label><br />
<textarea name="message" rows="15" cols="40">
</textarea><br />
<input type="submit" />
</form>
As per the mail() docs the message body should be passed as a single parameter. So it should look something more like:
mail( "info#website.co.uk", "Message via your website!", "$name\r\n $services\r\n $message", "From: $email");
According to php.net the correct use of the mail() function is:
<?
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
You are trying to send the additional data ($services) as a header.
Try to merge your $message and $service >
$message = $service . "\r\n\r\n" . $message;
mail( "info#website.co.uk", "Message via your website!",
$message, "From: $email" );
You can't just add more and more variables to mail(). There is only one parameter that specifies the content of the email, which would be the third one, as you can see in the official documentation:
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
If you want to have more than just $message in your mail, you need to put everything into one variable to be given to the function as content.
$content = $message;
$content .= "\n" . $services;
// etc...
mail($to, $subject, $content);
Try this
<?php
$email = $_POST['email'] ;
$name = $_POST['name'] ;
$services = $_POST['services'] ;
$message = $_POST['message'] ;
if (!isset($_POST['email'])) {
header( "Location: feedback.html" );
}
elseif (empty($email) || empty($message)) {
header( "Location: error.html" );
}
else {
mail( "info#website.co.uk", "Message via your website!",
$name . $services. $message . "From: $email" );
header( "Location: thankyou.html" );
}
?>