Giter Club home page Giter Club logo

Comments (30)

Mehran16007 avatar Mehran16007 commented on September 20, 2024

this is my php form

<style> .error { color: #FF0000; } </style>
<?php

require_once 'vendor/autoload.php';

use AlexaCRM\CRMToolkit\Client as OrganizationService;
use AlexaCRM\CRMToolkit\Settings;
use AlexaCRM\CRMToolkit\Entity\EntityReference;

$options = [
'serverUrl' => '*********',
'username' => '**********************',
'password' => '
',
'authMode' => 'OnlineFederation',
];

$serviceSettings = new Settings( $options );
$service = new OrganizationService( $serviceSettings );

$contact = $service->entity( 'contact' );
$contact->firstname = 'John';
$contact->lastname = 'Doe';
$contact->emailaddress1 = '[email protected]';
$guid = $contact->create();

// define variables and set to empty values
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (empty($_POST["name"])) {
        $nameErr = "Name is required";
    } else {
        $name = test_input($_POST["name"]);
        // check if name only contains letters and whitespace
        if (!preg_match("/^[a-zA-Z-' ]*$/", $name)) {
            $nameErr = "فقط حروف مجازه";
        }
    }

    if (empty($_POST["email"])) {
        $emailErr = "Email is required";
    } else {
        $email = test_input($_POST["email"]);
        // check if e-mail address is well-formed
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $emailErr = "Invalid email format";
        }
    }

    if (empty($_POST["website"])) {
        $website = "";
    } else {
        $website = test_input($_POST["website"]);
        // check if URL address syntax is valid (this regular expression also allows dashes in the URL)
        if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
            $websiteErr = "Invalid URL";
        }
    }

    if (empty($_POST["comment"])) {
        $comment = "";
    } else {
        $comment = test_input($_POST["comment"]);
    }

    if (empty($_POST["gender"])) {
        $genderErr = "Gender is required";
    } else {
        $gender = test_input($_POST["gender"]);
    }
}

function test_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
?>

<h2>PHP Form Validation Example</h2>
<p><span class="error">* required field</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
    Name: <input type="text" name="name" value="<?php echo $name; ?>">
    <span class="error">* <?php echo $nameErr; ?></span>
    <br><br>
    E-mail: <input type="text" name="email" value="<?php echo $email; ?>">
    <span class="error">* <?php echo $emailErr; ?></span>
    <br><br>
    Website: <input type="text" name="website" value="<?php echo $website; ?>">
    <span class="error"><?php echo $websiteErr; ?></span>
    <br><br>
    Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment; ?></textarea>
    <br><br>
    Gender:
    <input type="radio" name="gender" <?php if (isset($gender) && $gender == "female") echo "checked"; ?> value="female">Female
    <input type="radio" name="gender" <?php if (isset($gender) && $gender == "male") echo "checked"; ?> value="male">Male
    <input type="radio" name="gender" <?php if (isset($gender) && $gender == "other") echo "checked"; ?> value="other">Other
    <span class="error">* <?php echo $genderErr; ?></span>
    <br><br>
    <input type="submit" name="submit" value="Submit">
</form>

<?php
echo "<h2>Your Input:</h2>";
echo $name;
echo "<br>";
echo $email;
echo "<br>";
echo $website;
echo "<br>";
echo $comment;
echo "<br>";
echo $gender;
?>

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

222

how to solve this error?

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024

@Mehran16007 not sure what the error is as you didn't include it. Are you referring to the unresolved references? Have you run composer as documented?

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

@Mehran16007 not sure what the error is as you didn't include it. Are you referring to the unresolved references? Have you run composer as documented?

Thanks for your replay, No i didn't run composer i just copy the toolkit codes into my php form file and i got this error.

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

wwwwwww

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024

Well, you do need to run composer to bring vendor libraries and references in.

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

Well, you do need to run composer to bring vendor libraries and references in.

rrrrrrrr

Ok georged, i install composer in my project folder, now i got this error

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024

Your Dynamics 356 URL is d365.mehran.lab, I assume it's a private Dynamics 365 instance. It must be configured as Internet Facing Deployment instance + it must use https: protocol.

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

Your Dynamics 356 URL is d365.mehran.lab, I assume it's a private Dynamics 365 instance. It must be configured as Internet Facing Deployment instance + it must use https: protocol.

Ok, So i have to configure IFD internally, am i correct? But i got still same error in my php form code is this normall?

oooooo

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024

No it's not normal. You have not resolved the references. Have you run composer? Did the vendor folder get created? Does it contain the referenced libraries? This is more or less standard wiring.

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

1
2
3
4

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

No it's not normal. You have not resolved the references. Have you run composer? Did the vendor folder get created? Does it contain the referenced libraries? This is more or less standard wiring.

and this is my references, i dont now if it be correct or not

Ref

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024

@Mehran16007 you need to run composer. References will not resolve until you do.

$ composer require alexacrm/php-crm-toolkit:dev-master

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

@Mehran16007 you need to run composer. References will not resolve until you do.

$ composer require alexacrm/php-crm-toolkit:dev-master

where should i do that ? i did run this command in cmd with path of my project folder and the command create the vendor folder and composer.json in my project folder but i still get this error, what else shall i do ?

compose again

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

@Mehran16007 you need to run composer. References will not resolve until you do.

$ composer require alexacrm/php-crm-toolkit:dev-master

should i change these three path ? if yes, to where ?

3path

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024

run composer in the same folder as your test php file. that will create vendor folder and the references become valid.

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

run composer in the same folder as your test php file. that will create vendor folder and the references become valid.

I already did that George, look at the photos that i sent, here another thing i got this error on my wamp server menu, what is it? how to solve it? is it relate to previous error?

error

when i install composer i chose the wamp php path for the composer, can be for this?

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

May you please remote to my system and see what's going on.

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

run composer in the same folder as your test php file. that will create vendor folder and the references become valid.

I already have VENDOR folder in my test folder and it has all References

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024

@Mehran16007

the issue seems to be your php install/configuration. If you're able to run a simple 'hello, world' php code in the test folder then all references seems to be in place and you should be able to run our sample code as well.

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

@Mehran16007

the issue seems to be your php install/configuration. If you're able to run a simple 'hello, world' php code in the test folder then all references seems to be in place and you should be able to run our sample code as well.

There is no problem with running sample hello world or a simple php form in that folder, the problem begin where these two line of code, when i run the program in browser the error is not about that two line error its about the IFD configuration of dynamics crm and the certificate. I'm not php expert may you help me to solve these two line error, maybe with remote to my system as well.

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024

@Mehran16007 if the errors are about the IFD configuration then it's not a php problem at all. You must have IFD configured and use https otherwise you won't be able to connect to the instance.

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

@georged Where should i put this line "As a temporary cure, add 'ignoreSslErrors' => true to the Settings." to not check the certificate ?

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024

@Mehran16007 this is not the purpose of this flag and it's not going to work. The requirements are clear: the server must be configured for IFD and that includes correct SSL certificate. See documentation

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

@georged I configured IFD internally but I got this error, I think the error is because of my certificate coz its internal certificate.

Fatal error: Uncaught Exception: Could not retrieve WSDL at https://mehran.mehran.lab/XRMServices/2011/Organization.svc?wsdl in C:\wamp64\www\test\vendor\alexacrm\php-crm-toolkit\src\Client.php on line 2227

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

@georged I want to put this flag to not consider the SSL but I don't know where to put this flag ?

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024
$options = [
'serverUrl' => '*********',
'username' => '**********************',
'password' => '',
'authMode' => 'OnlineFederation',
ignoreSslErrors => false
];

It's not strictly speaking what it's there for but you can try.

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

@georged I test it with value of True but got this error.

Fatal error: Uncaught Exception: Invalid SOAP Response: HTTP Response 503 <TITLE>Service Unavailable</TITLE>

Service Unavailable


HTTP Error 503. The service is unavailable.

in C:\wamp64\www\test\vendor\alexacrm\php-crm-toolkit\src\Client.php on line 1274

from php-crm-toolkit.

georged avatar georged commented on September 20, 2024

@Mehran16007 most likely your deployment isn't configured correctly. I'm sorry but this has nothing to do with the toolkit and google is your best friend. For example, this could be one of the reasons : https://support.microsoft.com/topic/http-503-service-unavailable-error-while-accessing-the-microsoft-dynamics-crm-federation-metadata-url-after-configuring-the-claims-based-authentication-6a5dde13-19c3-89d1-f8f5-fe82e0ac7dd7

from php-crm-toolkit.

Mehran16007 avatar Mehran16007 commented on September 20, 2024

@georged I finally got it working, Thank you for all your replay George, you route me to the correct direction.

from php-crm-toolkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.