Joomla, Filezilla, Contact, changing automatic answer - ajax

I have a problem with my website. I made the lines where my problem lays thick(bottom). Here it is:
" **result = '<p style="color:white;"><?php echo** JText::_('VG_SK_CONTACT_SUCCESS'); ?></p>'; } else {
**result = '<p style="color:white;"><?php echo**
"
If I write between >< "Thank you for..." then it says in the automatic answer "Thank you for..." and there is another sentence which is maybe called by a function. I don't know very well programming, so can someone tell me maybe where I could find this data file, where I can change the automatic answer.
//CODE
// no direct access defined('_JEXEC') or die;
//library jimport('joomla.application.module.helper');
//vars //$class_sfx = htmlspecialchars($params->get('moduleclass_sfx')); $c_emailto = explode( '#', $params->get('emailto') ); $c_justdata = $params->get('justdata'); $c_justsocial = $params->get('justsocial');
echo '<div class="contactform"> <span class="error"></span> <span class="error"></span> <span class="error"></span> <span class="error"></span>
<form id="contactForm" method="post" action="">
<input type="hidden" name="emailto1" value="' . $c_emailto[0] . '" />
<input type="hidden" name="emailto2" value="' . $c_emailto[1] . '" />
<input type="text" name="contactName" id="contactName" class="requiredField" value="" placeholder="' . JText::_('VG_SK_CONTACT_NAME') . '" />
<input type="text" name="email" id="email" value="" class="requiredField email" placeholder="' . JText::_('VG_SK_CONTACT_EMAIL') . '" />
<textarea class="requiredField" name="comments" id="comments" placeholder="' . JText::_('VG_SK_CONTACT_MESSAGE') . '"></textarea>
<input type="hidden" name="submitted" id="submitted" value="true" />
<div class="clearfix"></div>
<button type="submit" name="submit" id="submitMsg" class="large_btn contact-btn">' . JText::_('VG_SK_CONTACT_SUBMIT') . '</button>
</form> <div id="note"></div>
</div>
<div class="contactinfo">
' . $c_justdata . ' ' . $c_justsocial . '
</div>'; ?>
<script> // mail-form jQuery(document).ready(function($){ $("#contactForm").submit(function(){ var str = $(this).serialize();
$.ajax({ type: "POST", url: "<?php echo JURI::base(); ?>modules/mod_circle_contact/ajax/send.php", data: str, success: function(msg){
$("#note").ajaxComplete(function(event, request, settings){ if(msg == 'OK') {
**result = '<p style="color:white;"><?php echo** JText::_('VG_SK_CONTACT_SUCCESS'); ?></p>'; } else {
**result = '<p style="color:white;"><?php echo** JText::_('VG_SK_CONTACT_FORGOT'); ?></p>'; }
$(this).html(result).fadeIn("slow"); $(this).html(result);
}); //alert(msg);
}
}); return false; }); }); </script>
//CODE
Thank you, greetings

You should change the strings inside the JText::_('VG_SK_CONTACT_FORGOT'); that is the VG_SK_CONTACT_FORGOT inside en-GB.tpl_vg_grettla.ini see this relevant answer: Customize Joomla Text

Related

Image is not uploading in CI

I am new in CI and I am trying to upload image but dont know why its not uploading,
Here is my view,
<form action="<?php echo site_url('admin/test/'.$param2.'/add'); ?>" enctype="multipart/form-data" method="post" id = 'mcq_form'>
<input type="hidden" name="question_type" value="mcq">
<div class="input-group">
<div class="custom-file">
<input type="file" class="custom-file-input" id="attachment" name="attachment" onchange="changeTitleOfImageUploader(this)">
<label class="custom-file-label" for="attachment"><?php echo get_phrase('attachment'); ?></label>
</div>
</div>
<div class="text-center">
<button class = "btn btn-success" id = "submitButton" type="button" name="button" data-dismiss="modal"><?php echo get_phrase('submit'); ?></button>
</div>
</form>
<script>
$('#submitButton').click( function(event) {
$.ajax({
url: '<?php echo site_url('admin/test/'.$param2.'/add'); ?>',
type: 'post',
data: $('form#mcq_form').serialize(),
success: function(response) {
if (response == 1) {
success_notify('<?php echo get_phrase('question_has_been_added'); ?>');
}else {
error_notify('<?php echo get_phrase('no_options_can_be_blank_and_there_has_to_be_atleast_one_answer'); ?>');
}
}
});
showLargeModal('<?php echo site_url('modal/popup/test/'.$param2); ?>', '<?php echo get_phrase('test'); ?>');
});
</script>
on Controller I am trying to get image data but dont know why its not fetching,
print_r($_FILES['attachment']['name']);
die();
I don't understand, what I am missing. Please help me out.
You can try it like this
<input type="file" name="logo" class="form-control" value="">
in your controller
$logo = '';
if (!empty($_FILES['logo']['name'])) {
/* Conf Image */
$file_name = 'profile_' . time() . rand(100, 999);
$configImg['upload_path'] = './uploads/profile/';
$configImg['file_name'] = $file_name;
$configImg['allowed_types'] = 'png|jpg|jpeg';
$configImg['max_size'] = 2000;
$configImg['max_width'] = 2000;
$configImg['max_height'] = 2000;
$configImg['file_ext_tolower'] = TRUE;
$configImg['remove_spaces'] = TRUE;
$this->load->library('upload', $configImg, 'logo');
if ($this->logo->do_upload('logo')) {
$uploadData = $this->logo->data();
$logo = 'uploads/profile/' . $uploadData['file_name'];
} else {
$this->custom_errors['logo'] = $this->logo->display_errors('', '');
}
}

Ajax code run on Local Host xamp but not working on Hosting?

HTML
I am running below code on localhost xamp. its running well.
when i upload code into hosting its not working (not sending mail)..
my mail file code is ok. I run mail file separate mail file is working.
when i use my mail file into ajax mail file not working..
<div class="col-md-6 contact-bottom bottom-frm-div">
<form action="" method="post" id="cnt-form" class="cnt-form">
<input type="text" value="First Name" name="name" placeholder="" onfocus="this.value='';" onblur="if (this.value == '') {this.value = 'First Name';}">
<input type="text" value="Last Name" name="lname" placeholder="" onfocus="this.value='';" onblur="if (this.value == '') {this.value = 'Last Name';}">
<input type="text" value="Email Address" placeholder="" name="email" onfocus="this.value='';" onblur="if (this.value == '') {this.value = 'Email Address';}">
<textarea placeholder="" name="msg" onfocus="this.value='';" onblur="if (this.value == '') {this.value = 'Message';}">Message</textarea>
<input type="submit" name="send" value="Submit" id="send">
</form>
<div id="loader3" style="display: none;">Success</div>
</div>
Ajax
$(document).ready(function(){
$(function(){
$('#cnt-form').submit(function(e){
e.preventDefault();
var form = $(this);
var post_url = 'contact-mail-file.php';
var post_data = form.serialize();
$('#loader3', form).html('<img src="https://upload.wikimedia.org/wikipedia/commons/b/b1/Loading_icon.gif" width="100px" /> Please wait...');
$.ajax({
type: 'POST',
url: post_url,
data: post_data,
success: function(msg) {
$(form).fadeOut(800, function(){
form.html(msg).fadeIn().delay(2000);
$('#loader3').show();
});
}
});
});
});
});
PHP Mail file
<?
if(isset($_POST['send']))
{
$name=$_POST['name'];
$lname=$_POST['lname'];
$email=$_POST['email'];
$message = $_POST['msg'];
$to='inderjeetoffice#gmail.com';
$subject = "Enquiry from Inderjeet - ".date('d F Y h:i:s A');
$from = $email;
$message = '<html><body><table border=0 width=554><tr><td colspan=2><p><b>Enquiry from Setyourbiz</b><br><br></p></td></tr><tr><td colspan=2 class=text4>FORM submitted at '.date('d F Y h:i:s A').'<br></td></tr>
<tr><td width=200 class=text3>Name :</td><td class=text3>'.$name.' '.$lname.'</td></tr>
<tr><td>Email Id :</td><td>'.$email.'</td></tr>
<tr><td>Message :</td><td>'.$message.'</td></tr>
</table></body></html>';
mail( $to, $subject, $message, "From:$from\r\nReply-to:$from\r\nContent-type: text/html; charset=us-ascii", "-f$to" );
$msg=urlencode("Your enquiry has been submitted successfully.");
echo "<script>alert('Your Query is Submited');</script>";
}?>
Edit
In hosting: PHP Version 5.4.45
In XAMP: PHP Version 5.6.24
PHP VERSION PLEASE ?
OF LOCAL AND LIVE BOTH ?
CHECK WITH PHPINFO()

Run PHP function without reloading doesnt work with AJAX

I know this question has been asked a lot, but I can't solve my problem.
I want to run the PHP function without reloading the page. Why does this not work? The php file is indexTest.php.
The page is just scrolling to the top and nothing works.
I am new to AJAX so I really dont know what to do.
HTML:
<script type="text/javascript">
function submitdata()
{
var nameForm=document.getElementById( "nameForm" );
var emailForm=document.getElementById( "emailForm" );
var messageForm=document.getElementById( "messageForm" );
$.ajax({
type: 'post',
url: 'indexTest.php',
data: {
name:nameForm,
email:emailForm,
message:messageForm
},
});
return false;
}
</script>
<form onsubmit="return submitdata()" method="POST" id="contactForm">
<input spellcheck="false" class="first" type="text" name="name" placeholder="name" id="nameForm">
<input spellcheck="false" class="first" type="text" name="email" placeholder="email" id="emailForm">
<textarea rows="8" spellcheck="false" class="last" type="text" name="message" placeholder="message" id="messageForm"></textarea>
<input type="submit" name="submit" value="" id="button">
</form>
PHP:
<?php
if(isset($_POST['submit'])){
$to = "*"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Invalid email format";
};
$first_name = $_POST['name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = "Email from: " . $from . "\n\n" . $first_name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo '<script language="javascript">';
echo 'alert("message successfully sent")';
echo '</script>';
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
The problem is that you are posting through the form itself, when you actually want to post through AJAX. Essentially, because you are calling your JavaScript function in onsubmit, the JavaScript will get run in addition to the default form submission.
What you need to do is disable default form submission with e.preventDefault();, and then run your JavaScript instead:
$("#contactForm").submit(function(e) {
e.preventDefault();
submitdata();
});
Hope this helps! :)

Active record codeigniter does not update database when passed thru Ajax

The problem is that when i use submit, codeigniter process the script cleanly. But when I passed the data thru ajax. script works fine. It even outputs the array when i use print_r. Its just that it doesn't update the database. everything is fine until the activerecord script.
Here is my controller script. (I just simplified it).
What I did was there is a script that would create an empty row. Thus, it will retrieve the Article id which will be used to save the article.
Here is the save article function.
Controller:
function saveArticle(){
$this->userarticle_model->trial();
}
Model:
function trial(){
$userid = $this->session->userdata('userid');
$articleId = $this->input->post('article_id');
$articleData = array(
'sfc_articleAuthor' =>$userid ,
'sfc_articleTitle' => $this->input->post('article_title'),
'sfc_articleContent' => $this->input->post('article_content'),
'sfc_articleStatus' => 'saved',
'sfc_articleTag' =>$this->input->post('article_tag'),
'sfc_articleCategory' => $this->input->post('article_category')
);
$this->db->where('sfc_articleId', $articleId);
$this->db->update('sfc_articles', $articleData);
}
AJAX:
(Sorry, I just copied this from a tutoral.)
$(document).ready(function(){
$('.save').click(function() {
$('#article_form').hide(0);
$('#message').hide(0);
var article_title = $('#article_title').val();
var article_tag = $('#article_tag').val();
var article_id = $('#articleId').val();
var article_category = $('#article_category').val();
var article_content = $('#article_form').find('.nicEdit-main').text();
var article_status = 'saved';
var dataString = 'article_title='+ article_title + '&article_tag=' + article_tag + '&article_category=' + article_category + '&article_content=' + article_content + '&article_status=' + article_status;
$.ajax({
type : 'POST',
url : 'http://localhost/ci_usage/index.php/article/saveArticle',
dataType : 'json',
data: dataString,
success : function(data){
$('#waiting').hide(500);
if (data.error === false)
$('#article_form').show(10);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
$('#article_form').hide(10);
$('#article_form').show(3);
}
});
return false;
});
});
View:
<?php echo form_open('article/processArticle',array('id'=>'article_form'));?>
<?php echo validation_errors(); ?>
<div id="sidebar_options">
<div class="sidebar_title">Article Settings</div>
<ul>
<li>
<label>Tags</label><br />
<input type="text" name="article_tag" size="15" value="<?php echo set_value('article_tag');?>" id="article_tag"/>
</li>
<li>
<label>Category</label><br />
<select name="article_category" id="article_category">
<option value="1">Test Category 1</option>
<option value="">Test Category 2</option>
<option value="">Test Category 3</option>
<option value="">Test Category 4</option>
</select>
</li>
<li>PDF version</li>
</ul>
</div>
<div id="option_panel">
<input type="text" name="article_title" size="30" placeholder="Title" value="<?php echo set_value('article_title');?>" id="article_title"/>
<input type="submit" value="Publish" name="publish" />
<input type="button" value="Preview" class="save"/>
<input type="button" value="Save" class="see"/>
</div>
<div id="write_panel" style="width:700px; margin-left:50px; width:800px;"></div>
<div id="write_area">
<textarea name="article_content" id="article_content" style="height:690px; width:800px;" ></textarea>
<input type="hidden" value="<?php echo $articleId;?>" name="article_id" id="articleId"/>
</div>
</div>
<?php echo form_close();?>
I really scratched my head on this.
Just got the answer. Forgot to add to put the last variable into the datastring in the ajax file.

How do i get the actual image to show on my page rather than the text?

<?php
require 'db.php';
include_once("header.php");
include_once("functions.php");
if(isset($_POST['search_term'])){
$search_term = mysql_real_escape_string(htmlentities ($_POST['search_term']));
if(!empty($search_term)){
$search = mysql_query("SELECT users.username, users.id, tbl_image.photo, tbl_image.userid FROM users LEFT OUTER JOIN tbl_image ON users.id=tbl_image.userid WHERE users.username LIKE '%$search_term%' and users.business <> 'business'");
$result_count = mysql_num_rows($search);
$suffix = ($result_count != 1) ? 's' : '';
echo '<div data-theme="a">Your search for <strong>' , $search_term ,'</strong> returned <strong>', $result_count,' </strong> record', $suffix, '</div>';
while($results_row = mysql_fetch_assoc($search)){
echo '<div data-theme="a"><strong>',$results_row['photo'], $results_row['username'], '</strong></div>';
$following = following($_SESSION['userid']);
if (in_array($key,$following)){
echo ' <div action= "action.php" method="GET" data-theme="a">
<input type="hidden" name="id" value="$key"/>
<input type="submit" name="do" value="follow" data-theme="a"/>
</div>';
}else{
echo " <div action='action.php' method='GET' data-theme='a'>
<input type='hidden' name='id' value='$key'/>
<input type='submit' name='do' value='follow' data-theme='a'/>
</div>";
}
}
}
}
?>
How do i get the actual image to show on the page rather than the name of the image. I have the images in the file system under a folder called image. How do I echo that image on screen or if echo is not the right way to do it how would you do it?
You mean like this?
echo '<img src="'.$results_row['photo'].'" width="80">';

Resources