Current location: Hot Scripts Forums » Programming Languages » PHP » Convert simple ASP to PHP


Convert simple ASP to PHP

Reply
  #1 (permalink)  
Old 10-27-06, 08:30 AM
ivoryguy36 ivoryguy36 is offline
New Member
 
Join Date: Oct 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Convert simple ASP to PHP

Hello,

I have a simple ASP script that was used to password protect a page with a 3 letter password known only to church members. Moved our website to a linux server, need to convert it to a PHP script. I'm not good with scripting so I used a couple of different converters, but I get parsing errors. Here's the ASP script:
Code:
<%Dim name%>

<%Dim password%>

<%name=Request.Form("name")%>

<%password=Request.Form("password")%>



<%If password="col" Then

	Response.Redirect "../realLife_studies.html"

Else

	Response.Redirect "../index.html"

End If%>



<%Dim admin%>

<%admin=request.Form("admin")%>



<%If admin="4111" Then

	Response.Redirect"../g12.html"

Else

	Response.Redirect"../realLife_studies.html"

End If%>
Now here's the conversion that won't work:
PHP Code:

<?php

 
/*
  ASP Translator Messages (These can be removed later)
  ----------------------------------------------------

  1. All "Dim" statements have been changed to comments for reference.

*/

?>
<?
//dim $name?>

<?//dim $password?>

<?$name=@$_POST["name"]?>

<?$password=@$_POST["password"]?>



<?if ($password=="col") {
 
    
Response.Redirect "../realLife_studies.html";
 
} else {
 
    
Response.Redirect "../index.html";
 
}
?>



<?//dim $admin?>

<?$admin=@$_POST["admin"]?>



<?if ($admin=="4111") {
 
    
Response.Redirect"../g12.html";
 
} else {
 
    
Response.Redirect"../realLife_studies.html";
 
}
?>
I get a parsing error on the first redirect line. Any help?

IV

Last edited by nico_swd; 10-27-06 at 08:34 AM. Reason: Please use [code] wrappers when posting code.
Reply With Quote
  #2 (permalink)  
Old 10-27-06, 08:34 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Replace
Code:
Response.Redirect"../g12.html";
with
PHP Code:

header('Location: ../g12.html'); 

Reply With Quote
  #3 (permalink)  
Old 10-27-06, 08:50 AM
ivoryguy36 ivoryguy36 is offline
New Member
 
Join Date: Oct 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks so much for the quick reply, but I tried header line with single quotes and double quotes and it did not work. I tried editing with notepad and wordpad saving in unicode format. Response from server is unreadable blocks.

IV
Reply With Quote
  #4 (permalink)  
Old 10-27-06, 09:17 AM
ivoryguy36 ivoryguy36 is offline
New Member
 
Join Date: Oct 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Here's the parsing error I get when I change the redirect lines to the header:

Warning: Cannot modify header information - headers already sent by (output started at /home/content/c/o/l/colmi/html/processPages/LeadProcess.php:14) in /home/content/c/o/l/colmi/html/processPages/LeadProcess.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at /home/content/c/o/l/colmi/html/processPages/LeadProcess.php:14) in /home/content/c/o/l/colmi/html/processPages/LeadProcess.php on line 46

Here's the code that generates the error so you can see I changed it:
PHP Code:

<?php

 
/*
  ASP Translator Messages (These can be removed later)
  ----------------------------------------------------

  1. All "Dim" statements have been changed to comments for reference.

*/

?>
<?
//dim $name?>

<?//dim $password?>

<?$name=@$_POST["name"]?>

<?$password=@$_POST["password"]?>



<?if ($password=="col") {
 
    
header('Location: ../realLife_studies.html');
 
} else {
 
    
header('Location: ../index.html');
 
}
?>



<?//dim $admin?>

<?$admin=@$_POST["admin"]?>



<?if ($admin=="4111") {
 
    
header('Location: ../g12.html');
 
} else {
 
    
header('Location: ../realLife_studies.html');
 
}
?>
Thanks...

IV
Reply With Quote
  #5 (permalink)  
Old 10-27-06, 09:21 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
You cannot send headers after outputting something to the browser. There are white spaces between the <?php tags which are probably causing the error. Try this
PHP Code:

<?php


$name
=@$_POST["name"];
$password=@$_POST["password"];

if (
$password=="col"){
 
    
header('Location: ../realLife_studies.html');
 
} else {
 
    
header('Location: ../index.html');
 
}

$admin=@$_POST["admin"];

if (
$admin=="4111") {
 
    
header('Location: ../g12.html');
 
} else {
 
    
header('Location: ../realLife_studies.html');
 
}

?>
And please use [php] wrappers when posting php code.
Reply With Quote
  #6 (permalink)  
Old 10-27-06, 05:32 PM
ivoryguy36 ivoryguy36 is offline
New Member
 
Join Date: Oct 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
No errors, but returns a blank page. Thanks...

IV
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
Needed - Someone who can convert asp to php dkaveritt Job Offers & Assistance 3 02-14-05 10:52 AM
convert ASP to PHP help needed! fantaziachat PHP 0 12-17-04 05:33 AM
Require ASP coder to convert some PHP BosDev Job Offers & Assistance 2 10-30-04 04:12 PM
ASP to PHP convert help! fantaziachat PHP 5 08-15-04 12:41 PM


All times are GMT -5. The time now is 05:44 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.