is it possible to check the Url with regex to validate?
URL looks: https://www.example.com/secure/index.phpID=name#specialDomain.com
in the domain our marketing division can input an mail address only with -> #domain.com or domain-marketing.com .
(marketing division input the email address in the Url, send the link to User, they input her data and send the form to the *#domain.com or *#domain-marketing.com)
thanks
Solve this issue:
$email = $_GET['ID']; // remember to filter this!
$regex = '#\w+#(?<domain>\w+\-?\w+\.\w+)#';
preg_match($regex, $email, $matches);
$domain = $matches['domain'];
if ($domain !== 'example-test.com') {
// Unauthorised
}
Related
I am attempting to validate a form field for an SCA (mont-blanc) site.
As I am not versed in SuiteScript code, but know Java, I simply need to know how to retrieve the POST value of a form field, so that I can do a check on the submission before submitting the form.
The below is not working - simply because I don't know the function / method to call to get the email address that is being submitted.
name: 'ContactUs',
create: function create( data ) {
try {
url = '<the-url>';
var email = nlapiGetContext.getEmail();
if (email.indexOf("qq.com") === -1) {
response = nlapiRequestURL(url, data);
responseCode = parseInt(respons...
To validate any field data you need to use client-script on the said record and based on your code and requirement, I think you want to validate Suitelet data(right?).
You can deploy client script on any record/suitelet and validate field data in saveRecord method. You can find client script help doc here.
Detecting the value in a data field in a submitted form is as simple as data['field_name']
In the above example - it would be:
name: 'ContactUs',
create: function create( data ) {
try {
url = '<the-url>';
**var email = data['email'];**
if (email.indexOf("qq.com") === -1) {
response = nlapiRequestURL(url, data);
responseCode = parseInt(respons...
I want to send a message to the user through PHPMailer to get the user's login to greet him - "Dear". $username. "!". How can i do this? Given that I used $mail->addAddress($email, $username); more than once.
I don't know exactly how you have your emails/usernames implemented but the basic answer is to use a for loop (or possibly a while loop depending on implementation). The following code assumes you have two arrays, one for emails and one for usernames and their indices are appropriately aligned.
for ($i=0; $i < count($emails); $i++) {
$message = "Dear ".$usernames[$i]."!";
//Recipients
$mail->addAddress($emails[$i]); // Add a recipient
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Hello!';
$mail->Body = $message;
$mail->AltBody = strip_tags($message);
$mail->send();
$mail->ClearAllRecipients( );
}
The trick is to use $mail->ClearAllRecipients( ); and then add the new recipient and their custom body/header.
My registration page URL like: www.exmpl.com/index.php?route=account/register when I submit after filled all fields then it redirect me to login page but I want to redirect it to thank you page.How can I do this?
This function (in /catalog/controller/account/register.php) is responsible for redirection ($this->response->redirect($this->url->link('account/success'));, to be more precise). Just need to check which page is "thank you" page (I'm not sure right now).
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$customer_id = $this->model_account_customer->addCustomer($this->request->post);
// Clear any previous login attempts for unregistered accounts.
$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
$this->customer->login($this->request->post['email'], $this->request->post['password']);
unset($this->session->data['guest']);
// Add to activity log
$this->load->model('account/activity');
$activity_data = array(
'customer_id' => $customer_id,
'name' => $this->request->post['firstname'] . ' ' . $this->request->post['lastname']
);
$this->model_account_activity->addActivity('register', $activity_data);
$this->response->redirect($this->url->link('account/success'));
}
I'm trying to submit a drupal 6 form PIA to a third party site for processesing, but after submitting the form, I need to redirect to a thank you page within my own site.
I've read this post - Drupal form submission to a 3rd party website
but i'm nor sure how to set up the redirect properly.
this is my code:
$form_state['#action'] = 'external site.com';
$form['#redirect'] = 'thankyou.com';
thanks
Make sure the redirect is the last step. Something like this:
function my_module_form {
$form['#action'] = 'some.external.site';
# Store the redirect in a value element, maybe we need some data
# which are passed to the form, like a user ID, node ID etc.
# So lets store the link in a value element
$form['redirect_link'] = array(
'#type' => 'value',
'#value' => url('some.redirect.page'),
);
}
function my_module_form_validate ($form, &$form_state) {
# Do some validation stuff...
}
function my_module_form_submit($form, &$form_state) {
# show some confirmation message...
drupal_set_message(t('Successfully sent your data into space.'));
# And finally the redirect...
# The 'redirect_link' value was passed internally, without being sent
# to the browser so we can safely use it.
$form_state['redirect'] = $form_state['values']['redirect_link']
}
Redirect property is also set in $form_state.
$form_state['redirect'] = 'some.com';
Since I'm only trying to send informtaion to a third party and not actually redirecting the page after form submission to a third party site.
I got the right answers tot he wrong question.
This is what I ended up using that worked for me:
$url = 'http://thirdpartyurl';
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
$data = drupal_query_string_encode($pass_the_form_info);
drupal_http_request($url, $headers, 'POST', $data);
In my VSTO Outlook 2007 plug-in, I am able to get the email address of a recipient which is an exchange user. But when I have the following case, it does not return me the smtp email:
Add a new Outlook Contact item (in Outlook contacts).
The email address of this Contact Item should be an email of an exchange user (any person of your organization, but that is an exchange user).
Now when I select this Outlook contact as email recipient and in item send event I cannot get the smtp address.
Below is my code:
Recipient r = mailItem.Recipients[i];
r.Resolve();
//Note, i have different conditions that check the AddressEntryUserType of recipient's
//address entry object. All other cases work fine. In this case this is
//olOutlookContactAddressEntry.
//I have tried the following:
ContactItem cont = r.AddressEntry.GetContact();
string email = cont.Email1Address;
string emailtmp = r.AddressEntry.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x800F101E") as string;
Can anyone please help me about what property I should use in this case to get smtp email?
I have found a way to use the ExchangeUser item and resolve the smtp address through that object. This post helped - Get Smtp email from ContactInfo stored in Exchange
foreach (Outlook.Recipient recipient in currentAppointment.Recipients)
{
Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
string smtpAddress;
if (exchangeUser != null)
{
smtpAddress = exchangeUser.PrimarySmtpAddress;
}
else
{
smtpAddress = recipient.Address;
}
}
If I recall correctly, there were several instances where email addresses wouldn't resolve unless you SAVED the item being sent first. You might try that. Also, are you not getting any "security violation" messages asking for permission to access the user's address book, or have you disabled/worked around all that stuff? I had lots of probs with that that ended up requiring using Redemption for outlook.