hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Web Hosting Talk Tutorials : Programming Tutorials : Convert Php to C# ?
Reply

Forum Jump

Convert Php to C# ?

Reply Post New Thread In Programming Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-30-2004, 10:55 AM
kf4mms kf4mms is offline
New Member
 
Join Date: Sep 2004
Location: Demorest, Ga
Posts: 0
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;



Sponsored Links
  #2  
Old 10-09-2004, 06:10 PM
Ricardob Ricardob is offline
Junior Guru Wannabe
 
Join Date: Oct 2004
Location: Canada
Posts: 61
Re: Convert Php to C# ?

Quote:
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  
Old 10-12-2004, 10:12 PM
kf4mms kf4mms is offline
New Member
 
Join Date: Sep 2004
Location: Demorest, Ga
Posts: 0
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

Sponsored Links
  #4  
Old 10-17-2004, 10:25 PM
Ricardob Ricardob is offline
Junior Guru Wannabe
 
Join Date: Oct 2004
Location: Canada
Posts: 61
Re: Re:

Quote:
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  
Old 06-29-2005, 09:52 AM
SuperSac SuperSac is offline
New Member
 
Join Date: Jun 2005
Posts: 3
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  
Old 07-11-2005, 04:39 AM
michael-lane michael-lane is offline
Junior Guru
 
Join Date: Mar 2005
Posts: 211
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  
Old 07-11-2005, 11:34 AM
SuperSac SuperSac is offline
New Member
 
Join Date: Jun 2005
Posts: 3
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  
Old 07-27-2005, 05:14 PM
Ricardob Ricardob is offline
Junior Guru Wannabe
 
Join Date: Oct 2004
Location: Canada
Posts: 61
Quote:
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  
Old 07-28-2005, 11:24 PM
freeboy1 freeboy1 is offline
WHT Addict
 
Join Date: Jan 2005
Posts: 129
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  
Old 07-29-2005, 05:19 AM
paulddaw paulddaw is offline
Disabled
 
Join Date: Jun 2004
Posts: 16
Re: Re: Convert Php to C# ?

Quote:
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  
Old 07-30-2005, 07:38 PM
leefig leefig is offline
Newbie
 
Join Date: Jul 2005
Posts: 5
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.

Reply

Related posts from TheWhir.com
Title Type Date Posted
Designer-Focused Website Builder Webydo Closes $7 Million Funding Round Web Hosting News 2014-06-24 12:11:52
Taking Volatility Out of Bitcoin For Web Hosts Web Hosting News 2014-02-03 16:46:52
QTS Realty Commences IPO at $21 A Share Web Hosting News 2013-10-09 14:38:55
CoreSite Reality Acquires New Jersey Building to Convert Into Data Center Web Hosting News 2013-02-26 15:38:26
CyrusOne Server Containment Units Boost Cooling Efficiency, Security, Privacy Web Hosting News 2012-09-18 15:49:19


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?