Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2004
    Location
    Demorest, Ga
    Posts
    2

    Question Convert Php to C# ?

    I need to convert Php to C# to add to an Asp page. How would I do this? Here is the code. Any help woul be greatly appreciated. Thanks,

    if (isset($Submit)==false) $Submit="";
    if (isset($Name)==false) $Name="";
    if (isset($Company)==false) $Company="";
    if (isset($EMail)==false) $EMail="";
    if (isset($Phone)==false) $Phone="";
    if (isset($Fax)==false) $Fax="";
    if (isset($Questions)==false) $Questions="";
    if (isset($ClassName)==false) $ClassName="";
    if (isset($ContactName)==false) $ContactName="";
    if (isset($ContactCompany)==false) $ContactCompany="";
    if (isset($ContactEMail)==false) $ContactEMail="";
    if (isset($ContactPhone)==false) $ContactPhone="";
    if (isset($ContactFax)==false) $ContactFax="";
    if ($Submit==""||$Name==""||$Company==""||$EMail==""||$Phone==""||$Fax=="")
    {
    if ($Name !="") $ContactName =$Name;
    if ($Company!="") $ContactCompany=$Company;
    if ($EMail !="") $ContactEMail =$EMail;
    if ($Phone !="") $ContactPhone =$Phone;
    if ($Fax !="") $ContactFax =$Fax;

  2. #2
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    76

    Re: Convert Php to C# ?

    Originally posted by kf4mms
    I need to convert Php to C# to add to an Asp page. How would I do this? Here is the code. Any help woul be greatly appreciated. Thanks,

    if (isset($Submit)==false) $Submit="";
    if (isset($Name)==false) $Name="";
    if (isset($Company)==false) $Company="";
    if (isset($EMail)==false) $EMail="";
    if (isset($Phone)==false) $Phone="";
    if (isset($Fax)==false) $Fax="";
    if (isset($Questions)==false) $Questions="";
    if (isset($ClassName)==false) $ClassName="";
    if (isset($ContactName)==false) $ContactName="";
    if (isset($ContactCompany)==false) $ContactCompany="";
    if (isset($ContactEMail)==false) $ContactEMail="";
    if (isset($ContactPhone)==false) $ContactPhone="";
    if (isset($ContactFax)==false) $ContactFax="";
    if ($Submit==""||$Name==""||$Company==""||$EMail==""||$Phone==""||$Fax=="")
    {
    if ($Name !="") $ContactName =$Name;
    if ($Company!="") $ContactCompany=$Company;
    if ($EMail !="") $ContactEMail =$EMail;
    if ($Phone !="") $ContactPhone =$Phone;
    if ($Fax !="") $ContactFax =$Fax;
    hmmm, I am pretty good with C# but pretty bad with PHP, If I understdood better what this is trying to do I could help



    something like this

    if (isset($Submit)==false) $Submit="";

    I am assuming that isset is a method and $Submit a string variable.


    you would have something like this in C#

    if (isset(Submit) == false)
    {
    Submit = "";
    }

    I don't think the C# compiler would like a variable name starting with $.

    Bear in mind that C# is strongly typed, so the variables types and return types of methods have to be carefully defined.

    is isset a PHP functions? what does it do?

  3. #3
    Join Date
    Sep 2004
    Location
    Demorest, Ga
    Posts
    2

    Re:

    Sorry it took me awhile to get back to you. This php code was used on our company website to check forms containing name, address and so forth. If any of these fields were blank, you couldn't submit until it the form was completed. Thank you very much for the reply. That gets me pointing in the right direction.

    -John

  4. #4
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    76

    Re: Re:

    Originally posted by kf4mms
    Sorry it took me awhile to get back to you. This php code was used on our company website to check forms containing name, address and so forth. If any of these fields were blank, you couldn't submit until it the form was completed. Thank you very much for the reply. That gets me pointing in the right direction.

    -John
    no problem, if you need more help let me know.

  5. #5
    here is a quick isset method ( in c# ) if you want, although I am sure you dont by now....


    private bool isSet(object o)
    {
    // check if the object is null
    if (o == null )
    return false;
    else
    return true;
    }

  6. #6
    right i just got a c# compiler and i want to know what are good sites for learning c# and how can you put c# programs in to webpages? if its possible? or only .exes allowed to be made?

  7. #7
    You can not ( well you can but its not the best way to handle it ) put EXE's in your website, however you can have DLL's in your website....

    http://www.asp.net is a good place to start looking for tutorials, or google "C# ASP.NET Tutorials" or something to that nature!

    ALso, for DLL imports, search for importing / using DLL's in your ASP.NET application.


    Good luck

    Post if you need a hand.....

  8. #8
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    76
    Originally posted by maddudemike
    right i just got a c# compiler and i want to know what are good sites for learning c# and how can you put c# programs in to webpages? if its possible? or only .exes allowed to be made?
    Regarding C#, there are numerous sites with tutorials, you can try GodDotNet.com, that has articles, tutorials, message boards, etc.

    However, keep in mind that a new version of .net (2.0) is going to be released in November.

    In C# the differences are not many, but important (such as generics or iterators), you can still start learning because those topics are advanced stuff.

    Regarding putting C# on a web page, well, it is a complex question, the answer is yes but...

    Basically, you can have different situations:

    1) you are running a web application. This has to be done through an ASP.net application, which only runs on IIS (that means, Windows). Basically, an asp.net page has an aspx extension, and normally the so called "code behind", that is the code that drives the page (similar to scripts in php or asp), the difference is that it's compiled in to .dll that it's then executed on the server to render the page.

    2) you can have class libraries written in C#, they will be .dll, they can have some functionality for your application (for example in the so called multi-tier applications) and they will be called from the .dll mentioned above (this is a simplification).

    3) I guess you could run a .dll in the cgi-bin, but I don't think anybody would do that now, still, you need the .net framework installed.

    4) you can indeed have an .exe on a web server and run it on a local machine, this is tricky though. It won't run on the server, it will actually download the file and run it on your local machine but, you need to have appropriate security policies in your machine, otherwise the OS won't run the code. Basically you need to have the website in your list of trusted sites to run code from, and you have to specify what that code can do. Not a very common scenario, it's theoretically possible but I don't see any use for it and it's dangerous, especially since with the new version of the framework, they implemented something called "click once" that allow you to deploy desktop application through the web (meaning, you download an installer).

  9. #9
    as SuperSac said you gona use bool and a fuction ,for example(hope thats what you mean) :

    if (fuction()==true)
    {
    cout << "submit= " << submit ;
    else {
    return;
    }
    }

    bool function(object submit)
    {
    if (submit == null )
    return false;
    else
    return true;
    }

  10. #10

    Re: Re: Convert Php to C# ?

    Originally posted by Ricardob
    hmmm, I am pretty good with C# but pretty bad with PHP, If I understdood better what this is trying to do I could help



    something like this

    if (isset($Submit)==false) $Submit="";

    I am assuming that isset is a method and $Submit a string variable.


    you would have something like this in C#

    if (isset(Submit) == false)
    {
    Submit = "";
    }

    I don't think the C# compiler would like a variable name starting with $.

    Bear in mind that C# is strongly typed, so the variables types and return types of methods have to be carefully defined.

    is isset a PHP functions? what does it do?
    isset = php.net/isset

    basically what it does is checks if the variable isnt blank or unset

  11. #11
    I would guess that you could use the HttpRequest object to check for the set status on the parameters that you are checking for using isset.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •