Thursday, January 21, 2016

Game ForgotPassword script Unity c sharp php

iklan

ForgotPassword Script :-
========================

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Text.RegularExpressions;
public class ForgotPassword : MonoBehaviour {
    public string username;
    public string emailid;
    string ForgotpasswordForUsername_url = "http://www.yourdomain.com/dr/ForgotPasswordForUsername.php";
    string ForgotpasswordForEmailid_url = "http://www.yourdomain.com/dr/ForgotPasswordForEmailid.php";
    public Text forgotusernametext;
    public Text sendingemailText;
    public string answer;
    public Image ForgotPasswordPanel;
    public Image LoginPanel;
    public InputField usernameInputField;
    public InputField passwordInputField;
    public Button loginButton;
    public Button forgotPasswordButton;
    public Button registerButton;

    IEnumerator RetrievePasswordForUsername()
    {
        username = forgotusernametext.text;
        WWWForm form = new WWWForm ();
        form.AddField ("username1", username);
        WWW download2 = new WWW (ForgotpasswordForUsername_url, form);
        yield return download2;
        answer = download2.text.ToString ();
        Debug.Log ("answer2 is" + answer);
        sendingemailText.text = answer;

        
    }
    IEnumerator RetrievePasswordForEmailid()
    {
        emailid = forgotusernametext.text;
        WWWForm form = new WWWForm ();
        form.AddField ("emailid1", emailid);
        WWW download2 = new WWW (ForgotpasswordForEmailid_url, form);
        yield return download2;
        answer = download2.text.ToString ();
        Debug.Log ("answer2 is" + answer);
        sendingemailText.text = answer;
        
    }
    public void SendButton()
    {
        string UserEmail = forgotusernametext.text;
        if (IsvalidEmailId (UserEmail)) {

            if ((forgotusernametext.text != "")  ) {
                StartCoroutine (RetrievePasswordForEmailid ());
                sendingemailText.text = "Loading.......";
            } 
            else 
            {
                sendingemailText.text = "* invalid  email";
            }
        } 
        else 
        {
            if ((forgotusernametext.text != "")  ) {
                StartCoroutine (RetrievePasswordForUsername ());
                sendingemailText.text = "Loading.......";
            } 
            else 
            {
                sendingemailText.text = "* invalid  Username";
            }

        }


    }
    public void BackButton()
    {
        loginButton.interactable = true;
        forgotPasswordButton.interactable = true;
        registerButton.interactable = true;
        usernameInputField.gameObject.SetActive(true);
        passwordInputField.gameObject.SetActive (true);
        ForgotPasswordPanel.gameObject.SetActive (false);
        LoginPanel.gameObject.SetActive (true);
    }
    public static bool IsvalidEmailId(string InputEmail)
    {
        Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,5})+)$");
        Match match = regex.Match (InputEmail);
        if (match.Success)
            return true;
        else
            return false;
    }
    public static bool IsValidUsername(string InputUsername)
    {
        Regex regex1 = new Regex("^[a-zA-Z]{8,12}$");
        Match match1 = regex1.Match (InputUsername);
        if (match1.Success)
            return true;
        else
            return false;
    }

}

Server Side Script :-
======================


<?php session_start();
$servername = "Your_ServerName"; 
$username = "Your_UserName";
$password = "************";
$dbname = "Your_DB_Name";


$conn = new mysqli($servername, $username, $password, $dbname); 


if ($conn->connect_error) { 
    die("Connection failed: " . $conn->connect_error); 
} 


$Username2=$_POST['username1'];
$Emailid2 = $_POST['emailid1'];
$Password2 = $_POST['password1'];
$sql = "SELECT * FROM userinfo where emailid = '$Emailid2' ";
$result  = $conn->query($sql); 
$count=mysqli_num_rows($result);
if($count == 1)
{   
    $rows=mysqli_fetch_array($result);

    $pass = $rows["password"];
    $to = $rows["emailid"];
    $from = "The Red & Black";
    $url = "http://www.thered.black/";
    $body = "Password recovery by The Team Of Red & Black <br>
        your password is : $pass, <br>
    sincerly, <br>
    The Red & black";
    $headers1 = "From: $from\n";
    $headers1 .= "Content-type: text/html;charset=iso-8859-1\r\n";
    $headers1 .= "X-Priority: 1\r\n";
    $headers1 .= "X-MSMail-Priority: High\r\n";
    $headers1 .= "X-Mailer: Just My Server\r\n";

    $subject = "Darkness Password recovered";
    $sentmail = mail($to,$subject,$body,$headers1);
}
else
{

    if (($_POST['emailid1'] != "emailid") ) {
        echo "Your emailid is  not found  to our database";
        # code...
    }

}
if (($sentmail == 1)) {
    echo "Password Sent by Your  email address $to ";
    # code...
}
else
{
    if($_POST['email']!="")
        echo "problem with sending mail";
}

$conn->close(); 

?>





Game ForgotPassword script Unity c sharp php
4/ 5
Oleh