Page 1 of 1

Some confusing source I need help figuring out

Posted: Fri Feb 11, 2005 12:50 pm
by irishmike2004
I got the following code from a client, they state that it is PHP but I have never seen anything like this and having never seen ASP, that is what I believe it is. Anyhow, we want to make a redirect based on a form select dropdown and that should be the action (from what I can make out)... can someone help me to put the proper PHP code in place of whatever this is.

Thanks,

Code: Select all

<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#003366">
     <center>
  <table width="326" border="0" cellpadding="0" cellspacing="2" bordercolor="#999999">
    <tr>
      <td><span class="whitebold">How did you hear about us? </span> 
        <form action = "<%= Request.ServerVariables("SCRIPT_NAME")%>" method="post">
          <span class="linkswh"><br>
          <input type = "radio" name = "page" value = "search" >
          Online Search Engine<br>
          <input type = "radio" name = "page" value = "marty">
          Member<br>
          <input type = "radio" name = "page" value = "print">
          Print Media (newspaper, magazine, publication)<br>
          <input type = "radio" name = "page" value = "radio">
          Radio<br>
          <input type = "radio" name = "page" value = "tv">
          TV Advertisement</span><br>
          <br>
<input type = "submit" value = "continue >>">
</form>

<%
'get the users selection from the form
strURL = Request.Form("page")
'depending on the users selection redirect to that page
Select Case lcase(strURL)
Case "search"
Response.Redirect "/index.php"
Case "memeber"
Response.Redirect "/contact.php"
Case "print"
Response.Redirect "/faqs.php"
Case "radio"
Response.Redirect "/maintenance.php"
Case "tv"
Response.Redirect "/pc_repair.php"
End Select 
%></td>
    </tr>
  </table>
  </center>
</body>
</html>
Thanks for any help in advance.

Posted: Fri Feb 11, 2005 12:56 pm
by djot
-
??
I also have never seen asp, but if you know any website related coding, you know what the asp? does here and to redo the same in a switch clause and a new header.

djot
-

Posted: Fri Feb 11, 2005 12:58 pm
by rehfeld
well, i dont know asp but it looks like thats what it is.

i would imagine this would be the php equivalent

Code: Select all

<?php

switch(strtolower($_POST&#1111;'page'])) &#123;

    case 'search':
        header('Location: index.php');
        break;
    case 'memeber':
        header('Location: contact.php');
        break;
// etc....
&#125;



?>

Posted: Fri Feb 11, 2005 1:07 pm
by feyd
yes it is asp, yes it is a simple switch statement with redirection.

Posted: Fri Feb 11, 2005 1:13 pm
by d3ad1ysp0rk
Also, this part:

Code: Select all

<form action = "<%= Request.ServerVariables("SCRIPT_NAME")%>" method="post">
is the same as:

Code: Select all

<form action="<?=$_SERVER&#1111;'PHP_SELF'];?>"> method="post">

Posted: Fri Feb 11, 2005 1:31 pm
by timvw
i've seen some php implementations of the Redirect class etc... but don't remember where ;)


probably http://asp2php.naken.cc/ is a good place to start :)

Thanks all

Posted: Fri Feb 11, 2005 1:33 pm
by irishmike2004
Hi Guys:

thanks for the help, think the suggestions worked out. Thanks for the help!

this works on my 5.0.3 but breaks on the clients 4.3 server

Posted: Fri Feb 11, 2005 6:14 pm
by irishmike2004
I am not sure if I understand why, but in reading the documentation, I assume it is because globals are off? Anyhow, below is my code as it works fine on PHP 5.0.3 on my machine but fails on the 4.3.x server it is meant to run on.

Code: Select all

<?php

$action = $_SERVER&#1111;'PHP_SELF'];

echo '
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#003366">
     <center>
  <table width="326" border="0" cellpadding="0" cellspacing="2" bordercolor="#999999">
    <tr>
      <td><span class="whitebold">How did you hear about us? </span> 
        <form action = "'.$action.'" method="post">
          <span class="linkswh"><br>
          <input type = "radio" name = "page" value = "search" >
          Online Search Engine<br>
          <input type = "radio" name = "page" value = "marty">
          Member<br>
          <input type = "radio" name = "page" value = "print">
          Print Media (newspaper, magazine, publication)<br>
          <input type = "radio" name = "page" value = "radio">
          Radio<br>
          <input type = "radio" name = "page" value = "tv">
          TV Advertisement</span><br>
          <br>
<input type = "submit" value = "continue >>">
</form>
</td>
    </tr>
  </table>
  </center>
</body>
</html>';

switch(strtolower($_POST&#1111;'page'])) &#123;

    case 'search':
        header('Location: index.php');
        break;
    case 'memeber':
        header('Location: contact.php');
        break;
    case 'print':
    	header('Location: faqs.php');
    	break;
    case 'radio':
    	header('Location: maintenance.php');
    	break;
    case 'tv':
    	header('Location: pc_repair.php');
    	break;
    
&#125; 


?>
we need to make this work with 4.3

Thanks again.

Posted: Fri Feb 11, 2005 6:41 pm
by feyd
why not download the exact version their server uses, copy the ini they run under and figure it out from there?

The posted code should work without much issue.. but that depends on what the error is.. any clue?