So I have created a custom form page that accepts applications from potential employees.
It worked fine before I added an ssl certificate but now is not sending any of the data along with the email.
It will send the Template email but not the data but I know that the data is making it to the controller.php as the sender in the Email is correct.
I bring the info into the controller as follows.
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
if (isset($this->error['fullname'])) {
$data['error_fullname'] = $this->error['fullname'];
} else {
$data['error_fullname'] = '';
}
Then send the data to my employment template where I believe the issue is
$html = $this->load->view('default/template/mail/employment.tpl',$data);
// This right here no Longer works after adding SSL
Then send the mail after attaching the HTML
$mail->setSender(html_entity_decode($this->request->post['fullname'], ENT_QUOTES, 'UTF-8'));
$mail->setHtml($html);
$mail->send();
This is located out side of the POST if statement to makesure the action on the form is using SQL
$data['action'] = $this->url->link('information/Employment', '', 'SSL');
Then in employment.tpl my email Template I will reference fullname
<?php echo $fullname ?>
I always receive the email but it is only the template never any of the data. I have tried using the full link with https:// on the $this->load->view but that does not work either.
Any help at all is greatly appreciated and will be glad to provide any additional information if needed.
Kindly check the ssh setting is working fine or not on your site.
system -> settings -> store edit and then check SSH setting.
it is just issue of the http => https or https => http
Please communicate on skype if not resolved.
skype: jks0586
Related
I have an application on Yii2.
I have an external vendor i want to redirect. For example, i am encrypting the current user info, and want to send that to the external vendor, so the user information is automatically populated on his website.
Everything works fine if i do that on the front end side using JS.
The problem i have is only my app server is whitelisted to the vendor. So i need to make the redirection happen on the backend.
I tried several method, and even with Guzzle HTTP, and it doesn't redirect.
TO be clear, i am not looking for a simple redirect, it is a form post on external URL.
I went though this post, but the problem remain the same...
Yii2 how to send form request to external url
Does anybody faced this issue?
If I understand you correctly, you want to POST data received from your frontend to the server of a third party company (let's call them ACME). Your webserver is whitelisted by ACME but your clients are not (which is good). You want to show a page on your server and not a page on the ACME server after the POST, right?
You have to send the data with a separate request from your server to the ACME server. You cannot create a HTML <form> and put the ACME server in the action parameter of it, because the request would be sent from the client and not your backend, failing at the whitelist. After you validate your client input, you can send it with guzzle to ACME.
With the status code you can decide if your request was successful or not. You can read more about guzzle here
The code sample below shows how you could POST the $payload (a fictional blog post if you will) as JSON to the ACME server and output a line with the request result.
$payload = [
'username' => 'john.doe',
'postContent' => 'Hello world',
];
$client = new GuzzleHttp\Client();
$response = $client->post('https://acme.example.org/endpoint',['http_errors' => false, 'json' => $payload]);
if($response->getStatusCode() === 200){
echo "Request OK";
}else{
echo "Request failed with status ".$response->getStatusCode();
}
I'm setting up comment moderation tool on a client's website, and in order to do that I need to create an app through facebook developer tools and create a webhook in order to be able to moderate comments.
When I try to set up the webhook, this is the error I receive.
The URL couldn't be validated. Response does not match challenge, expected value="716205142", received=""
And here's the code within the fbwebhook.php file:
<?php
$challenge = $_GET['hub_challenge'];
$verify_token = $_GET['hub_verify_token'];
if ($verify_token === 'TpQQFSkEJZbVlXZzCfEx') {
echo $challenge;
}
file_put_contents(
'log.txt',
"\n" . file_get_contents('php://input'),
FILE_APPEND
);
What is really driving me crazy is that this same file works on the staging site, works on other servers, but not on the server where the live site is being hosted.
We are on WPengine,
createwhimsy.staging.wpengine.com == webhook works
createwhimsy.com == webhook doesn't work (error above)
Tried on a digital ocean server == webhook works.
Tried on a different site being hosted on WPengine == webhook doesn't work (same error as above)
If I move the file I get a 404 error, so I know that FB is hitting the file, but it seems like FB isn't sending the right data to be used to verify, or something, not sure. This leads me to believe it's a DNS issue, or something with WPengine's hosting environment.
Any direction or input is much appreciated!
Discovered what is is.
WPengine has a redirect bot in place that will totally mess with facebooks validation post to your site. Just have to request them to disable the bot, and it worked just fine!
In my PHP project I want to integrate SMS gateway.
I have integrated HSPSMS SMS gateway.
They have given one API for this,but unfortunately I am unable to call this in proper way. I have called API after user successfully registered to site for sending SMS to user regarding same to notify he had successfully registered. Currently I am sending SMS for same but API's can send response back for SMS delivery(Successfully SMS sent or not in a JSON format).
Here is a problem- I am unable to caught the return response of SMS gateway,so it causes the Response is showing on user/Web Page.
It is a problematic for user.
For calling SMS gateway I have used PHP Header function like:
header("Location:URL of SMS Gateway");
My Code as Bellow,
<?php
include("otherpages/connection.php");
if(isset($_POST['submit1'])) {
$mname=$_POST['mname'];
$cdate=$_POST['cdate'];
$maddress1=$_POST['maddress'];
$mschool=$_POST['mschool'];
$mkendra=$_POST['centrename'];
$mmobile=$_POST['mmobile'];
$user=$_POST['user'];
$pass=$_POST['pass'];
$approved="0";
$qr="insert into tempregistration values('','$cdate','$mname','$maddress1','$mschool','$mschool','$mkendra','$mmobile','$user','$pass','$approved')";
// Code for Registration SMS
$url = 'http://sms.hspsms.com/sendSMS?username=#USERNAME#&message=Dear User,You Have Succeffully Registered to ABC.com ,Thanks&sendername=HSPSMS&smstype=PROMO&numbers=9503808004&apikey=#APIKey#';
header("Location:$url");
?>
Please help me on same or guide where I am doing right or wrong?
Any help will be appreciable.
You're sending the user's browser to the API, what you want to do is have PHP make the request and then tell the user if it was successful or not.
You may be able to use get_file_contents, but curl will give you more control.
You should have a function that will send the request to the API and return a success/failure and then display a message to the user.
Something like this (untested):
if(isset($_POST['submit1'])) {
$mname=$_POST['mname'];
$cdate=$_POST['cdate'];
$maddress1=$_POST['maddress'];
$mschool=$_POST['mschool'];
$mkendra=$_POST['centrename'];
$mmobile=$_POST['mmobile'];
$user=$_POST['user'];
$pass=$_POST['pass'];
$approved="0";
$qr="insert into tempregistration values('',
'$cdate','$mname','$maddress1','$mschool',
'$mschool','$mkendra','$mmobile','$user','$pass','$approved')";
//update to encode parameters which contain spaces
$message = urlencode('Dear User, You have successfully registered ...');
// other parametes might also contain spaces ...
$username = urlencode('#USERNAME');
$sendername = urlencode('HSPSMS');
//etc
$url = 'http://sms.hspsms.com/sendSMS?username='.$username
.'&message='.$message
.'&sendername='.$sendername
.'&smstype=PROMO&numbers=9503808004&apikey=#APIKey#';
if ($result = do_api_call($url)){
echo "SMS API returned:<br>";
echo $result;//for debugging
}else {
echo "Failure"
}
}
...
function do_api_call($url){
//this is very simplistic code to get you going ...
//use curl instead for more control
return file_get_contents($url);
}
I came across a great checkout solution called Gumroad. What I am trying to do is use their webhook functionality.
I have a Wordpress site, that when the user buys a product I will generate a user account based on their email.
With webhooks, they send a POST request to my endpoint which I have defined as www.mysite.com/gumroad. In here is where I want to grab the email address, then I will create the account and generate a password. What Gumroad expects me to return as stated on the page linked above is :
→ return an HTTP status code of 200
→ have a text/plain content type
→ contain only a URL (in the body)
I have no idea how to do this or what the code should look like.
Here is what I have so far and I know this isn't working but I can't figure out what exactly to do.
<?php
/* Template Name: Gumroad Test */
$email = $_POST['email'];
if( isset($email) ){
header("HTTP/1.1 200 OK");
echo "<h1>WEBHOOK WORKING</h1>";
}
?>
You only need to echo your full url instead of "<h1>WEBHOOK WORKING</h1>";
echo "http://www.example.com/sell";
I want to collect data from email to mysql database using php.
If some one is sent a mail to their mail account to my mail id. I want that mail information to store in my database. for further operation. It is possible in PHP because I saw this feature in one hosting support application Kayako Fusion which developed by PHP.
So plese give some information to do this task.
If you want to parse with PHP the best way is to use a 3rd party API to revive the email and then send it to your PHP script with a HTTP Post.
I'd recommend using either sendgrid.com or mailgun.com
Both of these services will parse the email and send you the information in a http POST that you can then insert into mysql. API docs for both: MailGun Incoming Parse API / SendGrid Incoming Parse API
You can use the imap functions, for example:
<?php
$imap = imap_open("{server.example.com:143}INBOX" , 'login' , 'password');
if( $imap ) {
//Check no.of.msgs
$num = imap_num_msg($imap);
//if there is a message in your inbox
if( $num >0 ) {
//read that mail recently arrived
$the_message = imap_body($imap, $num);
//Do the stuff with $the_message
}
//close the stream
imap_close($imap);
}
You'll have to setup a cronjob (scheduled task on Windows) that connects to the Exchange or POP server, retrieve's all new emails sinds the last run and insert them into the DB.
In case of a POP mail server(I think POP will be easier), there is a comment here with all functions you need right -> here. If that doesn't work, try Googling for "PHP POP wrapper" or something similar.
In case of a Microsoft Exchange server, you'd have to use a PHP Exchange wrapper, found one here for you.
Goodluck!
You can pipe your email to a php script and then extract each part of email and store it in data base.
check this example
when you get content of email you can do what ever you want