Re: ASP to PHP
| From: | Paul Roberts | Date: | Sun, 13 Apr 2003 16:53:45 +0000 |
| Subject: | Re: ASP to PHP | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143678@lists.php.net to get a copy of this message | ||
http://asp2php.naken.cc/ may help
Best Wishes
Paul Roberts
php at paul-roberts dot com
++++++++++++++++++++++++
----- Original Message -----
From: "linuxgeek" <php@fast.net>
To: "Tim Burgan" <burgan@iprimus.com.au>
Cc: "PHP Lists" <php-general@lists.php.net>
Sent: Sunday, April 13, 2003 4:50 PM
Subject: Re: [PHP] ASP to PHP
Hi Tim,
I'll get ya started. You really need to read the manual or buy a book,
your asking alot here.
<?
# Collect UserName from Form input
if (strlen($UserName) = 0) #you need a textbox in the form called UserName (case sensitive)
{
# no UserName entered
# NoUserName ()
echo "Please <b>re-enter</b> your UserName";
exit();
# Check to see if folder already exists
if( !$UserFolder = dirname("C:\inetpub\wwwroot\".$UserName));
{
# Create the user directory
new dir($UserFolder);
}
else
{
# first make sure the file exists
if( !$result = is_file("C:\inetpub\wwwroot\templates\referred.htm",
$UserFolder."\index.htm")
{
# add code here to create the file -- read the manual hint look for fopen() and
fwrite()
}
$return = copy("C:\inetpub\wwwroot\templates\referred.htm",
$UserFolder."\index.htm");
if( !$return )
{
echo "There is a problem copying the file";
exit();
}
else
{
# point them to the new file
header("Location:".$UserFolder."\index.htm");
}
}
}
else
{
# UserName already exists so call this function
UserNameExists();
echo"The Username you have selected <b>already exists</b>.Please try
again");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Enter your username</title>
</head>
<body>
<?
# Call NoUserName
# Call UserNameExists
?>
<form name="frmSelectUsername" action="move-files.php"
method="post">
Please <b>enter a Username</b> that you want to use<br>
<input type="text" name="UserName" size="20">
<input type="submit" value="Submit" name="submit">
</form>
</body>
</html>
LinuxGeek
Tim Burgan wrote:
>Here is some code in ASP that I want to convert to PHP.
>
>I honestly have no idea about much of PHP yet so I don't know where to start
>with this.
>
>If someone has a minute, can you please get me started til I get my head
>around the language
>
>Cheers
>
>----------ASP Code------------------------
><%
>
> ' Declare Variables
> Dim MoveFile, strUserName, strPath
>
> ' Collect UserName from Form input
> strUserName = Request.Form("UserName")
>
> If Len(strUserName) = 0 Then
> ' no UserName entered
> 'Sub NoUserName ()
> Response.Write("Please <b>re-enter</b> your UserName")
> 'End Sub
> End If
>
> ' Check to see if folder already exists
> strPath = "C:\inetpub\wwwroot\" & strUserName
>
> Set MoveFile = CreateObject("Scripting.FileSystemObject")
>
> ' If folder doesn't exist, create it & move file
> If Not MoveFile.FolderExists(strPath) Then
> MoveFile.CreateFolder(strPath)
> MoveFile.CopyFile "C:\inetpub\wwwroot\templates\referred.htm", strPath &
>"\index.htm"
> 'Response.Redirect strPath & "\index.htm"
>
> Else
> ' UserName already exists
> Sub UserNameExists ()
> Response.Write("The Username you have selected <b>already exists</b>.
>Please try again")
> End Sub
> End If
>
> SET MoveFile = Nothing
>
>%>
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
>
><html>
><head>
><title>Enter your username</title>
></head>
><body>
><%
> ' Call NoUserName
> ' Call UserNameExists
>%>
><form name="frmSelectUsername" action="move-files.asp"
>method="post">
> Please <b>enter a Username</b> that you want to use<br>
> <input type="text" name="UserName" size="20">
> <input type="submit" value="Submit" name="submit">
></form>
></body>
></html>
>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php